0

is it possible to change at runtime the route policy? for instance, if i have the code below

CronScheduledRoutePolicy startPolicy = new CronScheduledRoutePolicy();
startPolicy.setRouteStartTime("* 0 * * * ?");
startPolicy.setRouteStopTime("* 30 * * * ?");
from("direct:foo").routeId("myRoute").routePolicy(startPolicy).autoStartup(false).to("does://not-matter");

I would like to change the cron parameters during the camel execution. In JConsole I can just access to the getRoutePolicyList which returns

CronScheduledRoutePolicy(0x6dc7efb5)

Is it possible in some way access to the startPolicy object and re-instantiate it with a new value? Have I extend the mbean class of camel with some getter and setters?

0x41ndrea
  • 385
  • 5
  • 23

2 Answers2

0

No not out of the box. But yeah it would be a nice new feature to register the CronScheduledRoutePolicy as a JMX MBean so people can adjust it at runtime with JMX. I have logged a ticket: https://issues.apache.org/jira/browse/CAMEL-6334

What you can do is to stop the route. And then adjust the startPolicy settings, and then start the route again.

There is JMX operations for starting and stopping routes. What you may need is to expose some JMX operations to adjust the cron policy.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
0

I managed to do this using hawt.io. But for this to work, you need to upgrade to Camel version 2.13.0.

Using hawt.io, you can change cron expressions at runtime in a very user-friendly way.

abbasdgr8
  • 555
  • 1
  • 5
  • 15