0

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;

enter image description here

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>
Rizwan Sohaib
  • 1,240
  • 17
  • 27

1 Answers1

2

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.

David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Thanks David, I am almost there.. Please tell me how can I pass properties from mule-app.properties to the message of MuleEventContext of this java component. The problem is that I am getting endpoints of FTP server in MuleEventContext and file names as well. But I am not getting my file.inboundEndpoint location where the file on my local machine is saved. I need to know this property to process the downloaded file... – Rizwan Sohaib Dec 19 '13 at 10:46
  • Use Spring to inject these properties in your component. – David Dossot Dec 19 '13 at 15:19
  • I got is working.. referred to Object Factories at http://www.mulesoft.org/documentation/display/current/Configuring+Java+Components ... We need to simply create Setter Function in the sample class which implements Callable – Rizwan Sohaib Dec 20 '13 at 05:26
  • David, Can you please answer on this question; http://stackoverflow.com/questions/20704818/how-to-use-value-of-server-datetime-weekofyear-in-mule-app-properties-or-conf – Rizwan Sohaib Dec 20 '13 at 13:40