How to schedule a service using Quartz component that will invoke a file uploader on a periodic basis?

priyanka.sarkar picture priyanka.sarkar · Jan 23, 2013 · Viewed 10.1k times · Source

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

Answer

Niladri Biswas picture Niladri Biswas · Jan 28, 2013

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>