In this article, we will look into as how to transfer files on a periodic basis using the scheduler.
Introduction
Job scheduling can be done in Mule using Quartz component which we have seen earlier.In this article, we will look into as how to transfer files on a periodic basis using the scheduler.We will equally introduce ourself with the File Gobal Endpoint component in this exercise.
What we need to have for doing the experiment?
We need
- Download Mule ESB
- Everything should be up and running properly
Let us start the experiment
First create a Mule Project.Switch to the "Global Elements" tab.Click on the "Create" button.Look for Global Endpoints > File.Then click OK

From the Global Endpoint properties dialog box that opens, enter a suitable Name and Path information and leave the other fields as it is.

Next create a Quartz Inbound Endpoint and configure it as under
<quartz:inbound-endpoint
jobName="myServiceJob"
repeatInterval="5000"
doc:name="Quartz">
<quartz:endpoint-polling-job>
<quartz:job-endpoint ref="fileConnector"/>
</quartz:endpoint-polling-job>
</quartz:inbound-endpoint>
The job is schedule to run after every 5 seconds.The job-endpoint referes to the File Gobal Endpoint component which we already created by the name "fileConnector".
Next let us create a "File outbound" Endpoint and configure it as under
<file:outbound-endpoint
path="C:\Users\niladri.biswas\Desktop\outputfile"
responseTimeout="10000"
outputPattern="#[message.inboundProperties.originalFilename]"
doc:name="File"/>
The "OutputPattern" attribute of the "File Outbound" Endpoint indicates the pattern to use when writing a file to disk.
The flow looks as under

And the complete configuration file is as under
<file:endpoint
name="fileConnector"
path="C:\Users\niladri.biswas\Desktop\input"
pollingFrequency="5000"
doc:name="File"
responseTimeout="10000"/>
<flow name="fileUploader" doc:name="fileUploader">
<quartz:inbound-endpoint
jobName="myServiceJob"
repeatInterval="5000"
doc:name="Quartz">
<quartz:endpoint-polling-job>
<quartz:job-endpoint ref="fileConnector"/>
</quartz:endpoint-polling-job>
</quartz:inbound-endpoint>
<file:outbound-endpoint
path="C:\Users\niladri.biswas\Desktop\outputfile"
responseTimeout="10000"
outputPattern="#[message.inboundProperties.originalFilename]"
doc:name="File"/>
</flow>
Run the application
Now we will run the application.Let the Input folder content be as under

Once we run the application, we receive the beloow in the console
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'testfiletransfer' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2013-01-28 10:41:00,932 [[testfiletransfer].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.dispatcher.20078177'. Object is: FileMessageDispatcher
INFO 2013-01-28 10:41:00,932 [[testfiletransfer].connector.file.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.dispatcher.20078177'. Object is: FileMessageDispatcher
INFO 2013-01-28 10:41:00,984 [[testfiletransfer].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\Users\niladri.biswas\Desktop\outputfile\538557_514345138599164_783819682_n.jpg
INFO 2013-01-28 10:41:05,833 [scheduler-testfiletransfer_Worker-2] org.mule.module.client.MuleClient: Using existing MuleContext: org.mule.DefaultMuleContext@18a0b71
INFO 2013-01-28 10:41:05,855 [scheduler-testfiletransfer_Worker-2] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.requester.11336478'. Object is: FileMessageRequester
INFO 2013-01-28 10:41:05,855 [scheduler-testfiletransfer_Worker-2] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.requester.11336478'. Object is: FileMessageRequester
INFO 2013-01-28 10:41:05,861 [[testfiletransfer].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\Users\niladri.biswas\Desktop\outputfile\EMC IOMega LifeLine PoC – Technology & Integration - v1.5.docx
INFO 2013-01-28 10:41:10,829 [scheduler-testfiletransfer_Worker-3] org.mule.module.client.MuleClient: Using existing MuleContext: org.mule.DefaultMuleContext@18a0b71
INFO 2013-01-28 10:41:10,847 [scheduler-testfiletransfer_Worker-3] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.requester.10162050'. Object is: FileMessageRequester
INFO 2013-01-28 10:41:10,847 [scheduler-testfiletransfer_Worker-3] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.requester.10162050'. Object is: FileMessageRequester
INFO 2013-01-28 10:41:10,858 [[testfiletransfer].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\Users\niladri.biswas\Desktop\outputfile\Introduction_Windows8.pptx
INFO 2013-01-28 10:41:15,830 [scheduler-testfiletransfer_Worker-4] org.mule.module.client.MuleClient: Using existing MuleContext: org.mule.DefaultMuleContext@18a0b71
INFO 2013-01-28 10:41:15,850 [scheduler-testfiletransfer_Worker-4] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.requester.5910986'. Object is: FileMessageRequester
INFO 2013-01-28 10:41:15,850 [scheduler-testfiletransfer_Worker-4] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.requester.5910986'. Object is: FileMessageRequester
INFO 2013-01-28 10:41:15,860 [[testfiletransfer].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\Users\niladri.biswas\Desktop\outputfile\MVCDemo.zip
INFO 2013-01-28 10:41:20,829 [scheduler-testfiletransfer_Worker-5] org.mule.module.client.MuleClient: Using existing MuleContext: org.mule.DefaultMuleContext@18a0b71
INFO 2013-01-28 10:41:20,845 [scheduler-testfiletransfer_Worker-5] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.file.mule.default.requester.20298920'. Object is: FileMessageRequester
INFO 2013-01-28 10:41:20,845 [scheduler-testfiletransfer_Worker-5] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.file.mule.default.requester.20298920'. Object is: FileMessageRequester
INFO 2013-01-28 10:41:20,854 [[testfiletransfer].connector.file.mule.default.dispatcher.01] org.mule.transport.file.FileConnector: Writing file to: C:\Users\niladri.biswas\Desktop\outputfile\Q-_Bank_Windows_Forms.xlsx
And the output folder is filled with

Conclusion
Hope you have enjoyed the tutorial.More to come soon.