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.
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.
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.