使用“骡子请求者”并且FTP丢失了原始文件名 [英] Using "Mule Requester" and FTP loses originalFilename

查看:126
本文介绍了使用“骡子请求者”并且FTP丢失了原始文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个流量,当它被HTTP请求触发时,将从FTP服务器下载文件。为了按要求做到这一点,而不是投票,我使用了穆勒请求者。



我发现如果没有请求者,FTP连接器会为每个文件的inboundProperties集合设置incomingFilename。当与Mule Requester一起使用时,filename属性未设置,因此我不知道正在处理什么文件...或者在这种情况下保存到文件系统。在下面的代码中,我在文件名不通过的情况下使用'counter'变量作为文件名。



任何想法如何解决这个问题?这里是以下流程:

 < ftp:连接器名称=FTPConfigpollingFrequency =3000validateConnections =true DOC:名称= FTP >< / FTP:连接器> 


< flow name =FileRequestFlow>
< http:listener config-ref =HTTP_Listener_Configurationpath =csvfilesreadyallowedMethods =GETdoc:name =HTTP>< / http:listener>
< mulerequester:request-collection config-ref =Mule_Requesterresource =ftp:// username:pswd@127.0.0.1:21 / Incoming?connector = FTPConfigdoc:name =Mule Requester> ;< / mulerequester:请求收集>
< foreach collection =#[payload]doc:name =For Each>
< logger message =#['保存为'+ payload'的文件]level =INFOdoc:name =Logger>< / logger>
< / foreach>

< logger message =#[payload]level =INFOdoc:name =Logger>< / logger>
< / flow>


解决方案

UPDATE:
下面是与请求者一起工作,但是,可以使用请求集合。关键是要意识到它将返回一个MuleMessageCollection并在请求者之后直接使用Collection Splitter,然后它将单独返回具有originalFilename的ftp文件消息。






在玩了这段时间后,我发现使用mule请求程序中的FTP,只有在将它用作请求而不是请求集合时才能获取文件名。



如果您需要关联文件名,则无法使请求集合正常工作。

因此....如果你需要多个文件,你需要在请求者上做一些循环,直到有效载荷为空。



如果你有其他方法,请告诉我。


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>

解决方案

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.

这篇关于使用“骡子请求者”并且FTP丢失了原始文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆