骡子批次无法启动

时间:2016-10-06 12:58:50

标签: csv mule sftp batch-processing anypoint-studio

我创建了一个带有SFTP输入的Mule批处理作业,它不会检索csv文件。将相同的组件移动到工作流时,SFTP输入正确轮询并检索文件。

如何让SFTP输入轮询并检索输入文件?

Mule flow 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

由于

1 个答案:

答案 0 :(得分:0)

batch:input需要为batch:process-records生成一个Collection,Iterable等,因为它可以单独处理每条记录。您只是传递整个文件流。

同样在上面的用例中,根本不需要批处理模块,除非您计划添加每个记录处理。

有关所有步骤如何运作的更多信息:https://docs.mulesoft.com/mule-user-guide/v/3.7/batch-processing