How to schedule a service using Quartz component that will invoke a file uploader on a periodic basis?
Solution 1
Try this
<file:endpoint name="fileConnector" path="C:\input" pollingFrequency="5000" doc:name="File"/>
<flow name="fileUploader" doc:name="fileUploader">
<quartz:inbound-endpoint
jobName="myServiceJob"
repeatInterval="5000"
cronExpression="0 0 10 ? * WED"
doc:name="Quartz">
<quartz:endpoint-polling-job>
<quartz:job-endpoint ref="fileConnector"/>
</quartz:endpoint-polling-job>
</quartz:inbound-endpoint>
<file:outbound-endpoint
path="C:\outputfile"
responseTimeout="10000"
outputPattern="#[message.inboundProperties.originalFilename]"
doc:name="File"/>
</flow>
Solution 2
You have two options:
a. Replace the file inbound endpoint with a component that handles the File processing. It will be triggered by Quartz, pick up the file(s) from the folder and pass it to the outbound endpoint.
b. Don't use the Quartz endpoint and override org.mule.transport.file.FileMessageReceiver to implement your custom scheduling for polling files.
The first alternative is the easier one.
Comments
-
priyanka.sarkar almost 2 years
This is an extension of my previous question How to upload multiple files via REST over HTTP using Mule?. The requirement say that, on every Wednesday at 10AM the files has to be uploaded. Henceforth I need a scheduler for accomplishing this. And I found that the solution is "Quartz" inbound component with Cron Expression.
But how can I do so? Because I cannot have two "inbound-endpoint".(quartz and file) e.g.
<flow name="fileUploader" doc:name="fileUploader"> <quartz:inbound-endpoint jobName="myServiceJob" repeatInterval="5000" cronExpression="0 0 10 ? * WED doc:name="Quartz"> <quartz:event-generator-job/> </quartz:inbound-endpoint> <file:inbound-endpoint path="C:\input" pollingFrequency="5000" moveToDirectory="C:\movehere" doc:name="File" responseTimeout="10000"/> <object-to-byte-array-transformer doc:name="Object to Byte Array"/> <file:outbound-endpoint path="C:\outputfile" responseTimeout="10000" doc:name="File"/> </flow>
If I run I get error
Exception in thread "main" org.mule.module.launcher.DeploymentInitException: SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'file:inbound-endpoint'.
So what is the change that I need to do?
Please help
-
priyanka.sarkar over 11 yearsCould you please provide the configuration for point #a and #b?
-
justMe over 11 yearswhat I meant is to separate what you already have into two flows with one flow for each inbound you have and the same outbound for both. if that is not some ting you want to do search for <quartz:endpoint-polling-job> see if that helps
-
priyanka.sarkar over 11 yearsHi, could you please verify if the flow I put in the edit section is the one u r talking about
-
justMe over 11 yearsyes that is something that i thought it will work, I have added an example for <quartz:endpoint-polling-job> as an answer as it was too long for comment.
-
priyanka.sarkar over 11 yearscould you please tell about the connector-ref...what is the connector?
-
justMe over 11 yearsIt is in the documentations here mulesoft.org/documentation/display/MULE3USER/… not sure if you have an account with mule.