骡子批次将不会启动
Mule batch will not start
我创建了一个带有 SFTP 输入的 Mule 批处理作业,但它不会检索 csv 文件。当相同的组件移动到工作流时,SFTP 输入会正确轮询并检索文件。
如何获取 SFTP 输入以轮询和检索输入文件?
骡子流XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" 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/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd">
<ftp:connector name="FTP" pollingFrequency="1000" validateConnections="true" doc:name="FTP"></ftp:connector>
<sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP" pollingFrequency="10"></sftp:connector>
<http:request-config name="HTTP_Request_Configuration" host="${host}" port="${userprocess.port}" doc:name="HTTP Request Configuration"></http:request-config>
<batch:job name="userbatch">
<batch:input>
<sftp:outbound-endpoint exchange-pattern="request-response" connector-ref="SFTP" host="localhost" port="2222" path="//input" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" doc:name="SFTP"/>
</batch:input>
<batch:process-records>
<batch:step name="Batch_Step">
<object-to-string-transformer mimeType="application/csv" doc:name="Object to String"></object-to-string-transformer>
<object-to-byte-array-transformer doc:name="Object to Byte Array"></object-to-byte-array-transformer>
<logger message="#['Record ' +flowVars.counter +' being processed: ' + payload]" level="INFO" doc:name="Logger"></logger>
</batch:step>
</batch:process-records>
<batch:on-complete>
<sftp:outbound-endpoint exchange-pattern="one-way" connector-ref="SFTP" outputPattern="#[message.inboundProperties.originalFilename+'.processed']" host="localhost" port="2222" path="//output" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" duplicateHandling="addSeqNo" keepFileOnError="true" doc:name="SFTP"></sftp:outbound-endpoint>
</batch:on-complete>
</batch:job>
</mule>
CSV 文件:
1,user1
谢谢
batch:input
需要为 batch:process-records
生成一个 Collection、Iterable 等,因为它单独处理每条记录。您只是在传递整个文件流。
此外,在您上面的用例中,根本不需要批处理模块,除非您计划添加每条记录处理。
有关所有步骤如何运作的更多信息,请点击此处:https://docs.mulesoft.com/mule-user-guide/v/3.7/batch-processing
我创建了一个带有 SFTP 输入的 Mule 批处理作业,但它不会检索 csv 文件。当相同的组件移动到工作流时,SFTP 输入会正确轮询并检索文件。
如何获取 SFTP 输入以轮询和检索输入文件?
骡子流XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" 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/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd">
<ftp:connector name="FTP" pollingFrequency="1000" validateConnections="true" doc:name="FTP"></ftp:connector>
<sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP" pollingFrequency="10"></sftp:connector>
<http:request-config name="HTTP_Request_Configuration" host="${host}" port="${userprocess.port}" doc:name="HTTP Request Configuration"></http:request-config>
<batch:job name="userbatch">
<batch:input>
<sftp:outbound-endpoint exchange-pattern="request-response" connector-ref="SFTP" host="localhost" port="2222" path="//input" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" doc:name="SFTP"/>
</batch:input>
<batch:process-records>
<batch:step name="Batch_Step">
<object-to-string-transformer mimeType="application/csv" doc:name="Object to String"></object-to-string-transformer>
<object-to-byte-array-transformer doc:name="Object to Byte Array"></object-to-byte-array-transformer>
<logger message="#['Record ' +flowVars.counter +' being processed: ' + payload]" level="INFO" doc:name="Logger"></logger>
</batch:step>
</batch:process-records>
<batch:on-complete>
<sftp:outbound-endpoint exchange-pattern="one-way" connector-ref="SFTP" outputPattern="#[message.inboundProperties.originalFilename+'.processed']" host="localhost" port="2222" path="//output" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" duplicateHandling="addSeqNo" keepFileOnError="true" doc:name="SFTP"></sftp:outbound-endpoint>
</batch:on-complete>
</batch:job>
</mule>
CSV 文件:
1,user1
谢谢
batch:input
需要为 batch:process-records
生成一个 Collection、Iterable 等,因为它单独处理每条记录。您只是在传递整个文件流。
此外,在您上面的用例中,根本不需要批处理模块,除非您计划添加每条记录处理。
有关所有步骤如何运作的更多信息,请点击此处:https://docs.mulesoft.com/mule-user-guide/v/3.7/batch-processing