Reputation: 136
I am wondering if mule file connector always polls the source directory, or if this behavior can be overridden.
I configured an end point to read a file from FTP location using file connector and then process it. But my requirement is that the file should be read only when requested, for example when endpoint is called from Java. By controlling this behavior I can call endpoint point at the end of day and read all files placed at source during the day.
But mule keeps on polling the source location and downloads the file as soon as it is placed at the source. I tried to see if I can achieve my desired behavior by service override, but it does not seem obvious that it is possible.
Is there a different way to read a file from the source or can polling behavior be overridden in mule?
Upvotes: 1
Views: 860
Reputation: 136
With the pointer I received from @Jason and @anupambhusari, I was able to solve the issue I was facing. I am putting my mule flows below, hopping it will help others.
In below mule flow I was able call vm end point "fileReader" to download file from FTPserver and them copy it to local folder with the help of "CopyFile" flow.
<ftp:connector name="FTP_Connector" pollingFrequency="1000" validateConnections="true" doc:name="FTP"/>
<flow name="HTTP-RequestFlow">
<vm:inbound-endpoint exchange-pattern="request-response" path="/fileReader" doc:name="vm"/>
<mulerequester:request resource="ftp://<username>:<password>@<host>:<port>/<FTP resource Path>/?FTP_Connector" doc:name="Mule Requester"/>
<flow-ref name="CopyFile" doc:name="Copy File"/>
/flow>
<flow name="CopyFile" >
<file:outbound-endpoint path="output" outputPattern="#[message.inboundProperties.'originalFilename']" responseTimeout="10000" doc:name="File"/>
<set-payload value="Got a File" doc:name="Set Payload"/>
<logger message="Copying files on local disk #[message.payload]" level="INFO"/>
</flow>
Upvotes: 1
Reputation: 2415
You can achieve this is by following approaches
Hope this helps.
Upvotes: 3
Reputation: 113
If you can meet your requirement by setting the file polling for the end of the day and not having to trigger it through a Java program you can create a quartz job. See this question for a code example.
Upvotes: 0