Using “Mule Requester” and FTP loses originalFilen

2019-04-15 20:20发布

I am working on a flow that will, when triggered by an HTTP request, download files from an FTP server. In order to do this on request, instead of on polling, I am using the Mule Requester.

I have found that without the requestor, FTP connector will set the "incomingFilename" on the inboundProperties collection for each of the files. When used with the Mule Requester, the filename property is not set, therefore I have no idea what file I am processing... or in this case saving to the file system. In the code below I am using the 'counter' variable for thefilename in the case the the filename doesn't come through.

Any idea how to fix this issue? Here is the flow below:

<ftp:connector name="FTPConfig" pollingFrequency="3000" validateConnections="true" doc:name="FTP"></ftp:connector>


<flow name="FileRequestFlow"> 
        <http:listener config-ref="HTTP_Listener_Configuration" path="csvfilesready" allowedMethods="GET" doc:name="HTTP"></http:listener>  
        <mulerequester:request-collection config-ref="Mule_Requester" resource="ftp://username:pswd@127.0.0.1:21/Incoming?connector=FTPConfig" doc:name="Mule Requester"></mulerequester:request-collection>
                <foreach collection="#[payload]" doc:name="For Each">
        <set-variable variableName="thefilename" value="#[message.inboundProperties.originalFilename==null ? counter.toString()+'.csv' : message.inboundProperties.originalFilename] " doc:name="Variable"/> 
        <file:outbound-endpoint path="/IncomingComplete" outputPattern="#[flowVars.thefilename]" responseTimeout="10000" doc:name="File"></file:outbound-endpoint>
        <logger message="#['File saved as:  ' + payload]" level="INFO" doc:name="Logger"></logger>  
    </foreach>

        <logger message="#[payload]" level="INFO" doc:name="Logger"></logger>  
    </flow>

标签: ftp mule esb
2条回答
来,给爷笑一个
2楼-- · 2019-04-15 21:03

I have written an alternate ftp-connector, it allows to issue a list-command in the flow, followed by a loop to read the files.

See: https://github.com/rbutenuth/ftp-client-connector/

查看更多
Deceive 欺骗
3楼-- · 2019-04-15 21:07

UPDATE: Below is an option for working with the requester, however, you can use the request-collection. The key is to realize that it will return a MuleMessageCollection and to use the Collection Splitter directly after the Requester, which will then returning individually the ftp file messages with the originalFilename.


After playing with this a while, I have found that with FTP in the mule requester you can get the filename only if you use it as a request, not request-collection.

Have not been able to get the request-collection to work if you need filenames associated.

So.... If you need multiple files, you need do something like loop on the requester until the payload is null.

If you have alternate methods please let me know.

查看更多
登录 后发表回答