I want to control when my route starts up using a RoutePolicy
. Therefore I have defined it with autoStartup=false
<camel:route id="myRoute" routePolicyRef="myRoutePolicy" autoStartup="false">
<!-- details omitted -->
</camel:route>
To start the route, I tried:
public class MyRoutePolicy implements RoutePolicy {
// Does NOT work!
@Override
public void onInit(Route route) {
if(shouldStartRoute(route)) {
camelContext.startRoute(route.getId());
}
}
// More stuff omitted
}
Unfortunately, nothing happens. The Javadoc for CamelContext.startRoute(String)
may explain why:
Starts the given route if it has been previously stopped
How do I start a route that hasn't previously been stopped?
I'm using Camel 2.8.0 and upgrading is not an option.
I can start the route using a JMX console, but I don't want to depend on JMX.
camelContext.startRoute("myRoute");
from a route policy in an attempt to start the route – Stijn Van Bael