Reputation: 590
This is my schedular(CronScheduledRoutePolicy) for data processing.
<route>
<from uri="quartz://schedule?cron=0+1+0+*+*+?+*"/>
<bean ref="processData" method="scheduleData" />
<convertBodyTo type="java.util.List" />
<to uri="activemq:queue:DATA.GENERATEDLIST?mapJmsMessage=false" />
<onException>
<exception>java.lang.Exception</exception>
<to uri="activemq:queue:DATA.ERROR.MESSAGES?mapJmsMessage=false&jmsMessageType=Text" />
</onException>
</route>
It runs everyday 12.01 am, the question is if any error occurs how to re-run or re-schedule manually using schedule id or route id.
Thanks.
Upvotes: 0
Views: 2406
Reputation: 40408
Ok, since you have clarified your question, you need 2 ways to be able to do your data processing: firstly via the cron schedule and then manually.
I am going to suggest you break it into 3 routes (this is obviously java DSL, but you can easily convert it to xml).
First route is the quartz schedule- it calls the processing route.
from("quartz://schedule?cron=0+1+0+*+*+?+*")
.to("direct:doProcessing")
;
Second route does the processing
from("direct:doProcessing")
// do awesome stuff here...
;
Third route is your manual restart
from("timer://manualRestart?repeatCount=1")
.routeId("manualRestart")
.noAutoStartup()
.to("direct:doProcessing")
;
Now, you can start the route with id "manualRestart" using the route-start
command on the command line, or via a tool like fmc
.
Hope this helps.
Upvotes: 3
Reputation: 6853
You could use a re-delivery policy to re-try the exchange N times if an exception is encountered.
<route>
<!-- ... -->
<onException>
<exception>java.lang.Exception</exception>
<redeliveryPolicy redeliveryDelay="100000" maximumRedeliveries="3"/>
<to uri="activemq:queue:DATA.ERROR.MESSAGES?mapJmsMessage=false&jmsMessageType=Text" />
</onException>
</route>
Upvotes: 1