3

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

Community
  • 1
  • 1
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173

4 Answers4

4

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>
priyanka.sarkar
  • 25,766
  • 43
  • 127
  • 173
Niladri Biswas
  • 4,153
  • 2
  • 17
  • 24
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.

Seba
  • 2,319
  • 15
  • 14
0

The following just a work round if you couldn't find the exact what you need.

1- You could have 2 flows instead of one, one to do the normal job with normal inbound and one for quartz:inbound-endpoint.

2- You could make your scheduler to put messages on a queue and have an other flow to pick up messages from that queue and process.

3- You could have a component with quartz:inbound-endpoint as suggested here http://blogs.mulesoft.org/using-quartz-to-trigger-a-service/

Hope one of the above helps.

justMe
  • 2,200
  • 16
  • 20
  • what 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 see if that helps – justMe Jan 24 '13 at 11:11
  • Hi, could you please verify if the flow I put in the edit section is the one u r talking about – priyanka.sarkar Jan 24 '13 at 11:20
  • yes that is something that i thought it will work, I have added an example for as an answer as it was too long for comment. – justMe Jan 24 '13 at 11:23
0

Sorry couldn't put this as a comment as it is too long so here it is an example for <quartz:endpoint-polling-job> from Mule website:

<service name="testService5">
  <description>
  The endpoint polling Job will try and perform a 'request' on any Mule endpoint. If a result is received it will be handed off to this 'testService5' service for processing. The trigger will fire every 5 minutes starting at 2pm and ending at 2:55pm, every day. during this period the job will check the file directory /N/drop-data/in every 5 minutes to see if any event data is available. The request will timeout after 4 seconds if there are no files in the directory. 
  </description>

  <inbound>
    <quartz:inbound-endpoint name="qEP5" cronExpression="0 0/5 14 * * ?" jobName="job5"
           connector-ref="quartzConnector1">
      <quartz:endpoint-polling-job>
        <quartz:job-endpoint address="file:///N/drop-data/in" timeout="4000"/>
      </quartz:endpoint-polling-job>
    </quartz:inbound-endpoint>
  </inbound>
</service>

Hope the above helps

justMe
  • 2,200
  • 16
  • 20
  • could you please tell about the connector-ref...what is the connector? – priyanka.sarkar Jan 24 '13 at 11:29
  • It is in the documentations here http://www.mulesoft.org/documentation/display/MULE3USER/Quartz+Transport+Reference not sure if you have an account with mule. – justMe Jan 24 '13 at 11:34