通过 http 适配器调用时,Mulesoft filecopy 不起作用
Mulesoft filecopy not working when invoked via http adapter
我试图在通过某些 http url 调用时将文件从一个本地文件夹复制到另一个本地文件夹,但它不起作用。在我的目标文件夹中,一些垃圾文件正在创建,扩展名为 .dat
源文件夹 - so1
目标文件夹 - so2
这是我在调用 http 端点时在 mule 控制台中收到的消息
INFO 2017-10-27 14:02:45,346 [[each].HTTP_Listener_Configuration.worker.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'File.dispatcher.33168380'. Object is: FileMessageDispatcher
INFO 2017-10-27 14:02:45,467 [[each].HTTP_Listener_Configuration.worker.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'File.dispatcher.33168380'. Object is: FileMessageDispatcher
INFO 2017-10-27 14:02:45,488 [[each].HTTP_Listener_Configuration.worker.01] org.mule.transport.file.FileConnector: Writing file to: D:\so21cebe0-baf1-11e7-9534-0c7b20524153.dat
这里是配置XML
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />
<file:connector name="File" writeToDirectory="D:\so2" readFromDirectory="D:\so1" autoDelete="false" streaming="true" validateConnections="true" doc:name="File" />
<flow name="eachFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/copy" doc:name="HTTP" />
<file:outbound-endpoint path="D:\so1" connector-ref="File" responseTimeout="10000" doc:name="File" />
<set-payload value="files copied" doc:name="Set Payload" />
</flow>
</mule>
没有您正在读取配置文件的位置。
在您的方案中,文件出站端点只是创建一个新文件,其负载为空,文件扩展名未知。
有两种方式,
1) 除了 HTTP 入站,您可以使用文件入站来读取文件然后复制。
2) 如果必须使用 HTTP 入站来按需复制文件,请在配置中间使用 mule requester 组件读取文件然后复制。
如何使用mule requester,可以查看这里https://www.ricston.com/blog/reading-file-middle-flow-mule-requester/
更新:
请参阅以下配置以使用 Mule 请求程序从一个文件夹中读取所有文件并复制到另一个文件夹。
<http:listener-config name="HTTP_Listener_Configuration"
host="localhost" port="8086" doc:name="HTTP Listener Configuration" />
<file:connector name="File"
autoDelete="true" streaming="false"
validateConnections="true" doc:name="File" moveToDirectory="C:\FilePOC\so2"/>
<flow name="Flow1">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/copy" doc:name="HTTP" />
<mulerequester:request-collection resource="file:///C:/FilePOC/so1?connector=File" doc:name="Mule Requester"/>
<set-payload value="File copy has been successful." doc:name="Set Payload"/>
</flow>
在这里,不需要使用文件出站组件来复制文件。文件连接器上的 moveToDirectory 选项会在文件被读取后移动文件。
可以在此处找到有关如何将 Mule 请求程序与 JMS 一起使用的其他示例 https://www.slideshare.net/anir37/using-mule-requester-for-jms
我试图在通过某些 http url 调用时将文件从一个本地文件夹复制到另一个本地文件夹,但它不起作用。在我的目标文件夹中,一些垃圾文件正在创建,扩展名为 .dat
源文件夹 - so1
目标文件夹 - so2
这是我在调用 http 端点时在 mule 控制台中收到的消息
INFO 2017-10-27 14:02:45,346 [[each].HTTP_Listener_Configuration.worker.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'File.dispatcher.33168380'. Object is: FileMessageDispatcher
INFO 2017-10-27 14:02:45,467 [[each].HTTP_Listener_Configuration.worker.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'File.dispatcher.33168380'. Object is: FileMessageDispatcher
INFO 2017-10-27 14:02:45,488 [[each].HTTP_Listener_Configuration.worker.01] org.mule.transport.file.FileConnector: Writing file to: D:\so21cebe0-baf1-11e7-9534-0c7b20524153.dat
这里是配置XML
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />
<file:connector name="File" writeToDirectory="D:\so2" readFromDirectory="D:\so1" autoDelete="false" streaming="true" validateConnections="true" doc:name="File" />
<flow name="eachFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/copy" doc:name="HTTP" />
<file:outbound-endpoint path="D:\so1" connector-ref="File" responseTimeout="10000" doc:name="File" />
<set-payload value="files copied" doc:name="Set Payload" />
</flow>
</mule>
没有您正在读取配置文件的位置。
在您的方案中,文件出站端点只是创建一个新文件,其负载为空,文件扩展名未知。
有两种方式,
1) 除了 HTTP 入站,您可以使用文件入站来读取文件然后复制。
2) 如果必须使用 HTTP 入站来按需复制文件,请在配置中间使用 mule requester 组件读取文件然后复制。
如何使用mule requester,可以查看这里https://www.ricston.com/blog/reading-file-middle-flow-mule-requester/
更新:
请参阅以下配置以使用 Mule 请求程序从一个文件夹中读取所有文件并复制到另一个文件夹。
<http:listener-config name="HTTP_Listener_Configuration"
host="localhost" port="8086" doc:name="HTTP Listener Configuration" />
<file:connector name="File"
autoDelete="true" streaming="false"
validateConnections="true" doc:name="File" moveToDirectory="C:\FilePOC\so2"/>
<flow name="Flow1">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/copy" doc:name="HTTP" />
<mulerequester:request-collection resource="file:///C:/FilePOC/so1?connector=File" doc:name="Mule Requester"/>
<set-payload value="File copy has been successful." doc:name="Set Payload"/>
</flow>
在这里,不需要使用文件出站组件来复制文件。文件连接器上的 moveToDirectory 选项会在文件被读取后移动文件。
可以在此处找到有关如何将 Mule 请求程序与 JMS 一起使用的其他示例 https://www.slideshare.net/anir37/using-mule-requester-for-jms