Mule: How to pass File from FTP to Java class in Mule ESB?

元气小坏坏 提交于 2019-11-28 06:44:15

问题


In Mule, I am downloading files from FTP server. I want to pass all the files in this directory to my java class which should be performing actions after Download_ZIP_File in my flow. I need to perform actions like reading text files and unzip the zipped files using Java.

There should be a Java class in my flow, for which a function call should be raised when download is complete.. Object of this class must know all the information about downloaded files.

Can someone please help on this.? Here is my current flow;

My XML for this flow is like this;

 <?xml version="1.0" encoding="UTF-8"?>

 <mule xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp"
        xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 
        ... >
    <file:endpoint name="Download_File_KBB" responseTimeout="10000" doc:name="File" path="E:\csv\output"/>
    <file:connector name="Global_File_Connector" autoDelete="false" streaming="false" validateConnections="true" doc:name="File"/>
    <flow name="ftp_kbb_download_fileFlow1" doc:name="ftp_kbb_download_fileFlow1">
       <ftp:inbound-endpoint host="${ftp.host}" port="${ftp.port}" path="${ftp.pathInbound}" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" doc:name="KBB_FTP">
       </ftp:inbound-endpoint>
       <logger message="KBBUsedVehiclesNoSpecTabFormat-#[server.dateTime.year]-W#[server.dateTime.weekOfYear]" level="INFO" doc:name="Logger"/>
       <file:outbound-endpoint path="${file.inboundEndpoint}" outputPattern="#[header:originalFilename]" responseTimeout="10000" doc:name="Donwload_ZIP_FILE" connector-ref="Global_File_Connector"/>
    </flow>
  </mule>

回答1:


One option is to create a class that implements org.mule.api.lifecycle.Callable then configure it with a component element in your config.

Then, you will have full access to the MuleEventContext in the onCall method of this Callable class.



来源:https://stackoverflow.com/questions/20657425/mule-how-to-pass-file-from-ftp-to-java-class-in-mule-esb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!