Reputation: 4085
I am in the process of developing a message router and part of my design is stopping/suspending and starting/resuming routes based on some file commands dropped in a control route.
I tried to follow the camel recommendations to favor suspend/resume a route as an alternative to stop/start it.
My resume logic depends of the state of some routes say I have two routes ABC and XYZ that cannot be active at the same time. To facilitate this my control route supports two commands SUSPEND <route id> and RESUME <route id>
. So in short RESUME XYZ
will do nothing if route ABC is not suspended.
My unit tests (using JMockit) passed OK. However when running the real application I could see the route XYZ never resumes even if I suspended the route ABC before.
I put some log entries and to my surprise after executing the route.suspend("ABC")
apparently successfully giving the camel log entries the route ABC still reports as not suspended. This is the code:
LOGGER.info(r.getId() + " route supports suspension=" + r.supportsSuspension());
context.suspendRoute(r.getId());
LOGGER.info("After suspending route " + r.getId() + " the route suspended state is " + ((ServiceSupport) r).isSuspended());
And below are the log entries:
[INFO ] my.org.message.router.lifecycle.DeactivateCommand - ABC route supports suspension=true
[INFO ] org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds)
[INFO ] org.apache.camel.impl.DefaultShutdownStrategy - Route: ABC suspend complete, was consuming from: Endpoint[abc://queue:SOME_QUEUE]
[INFO ] org.apache.camel.impl.DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds
[INFO ] org.apache.camel.spring.SpringCamelContext - Route: ABC is suspended, was consuming from: Endpoint[abc://queue:SOME_QUEUE]
[INFO ] my.org.message.router.lifecycle.DeactivateCommand - After suspending route ABC the route suspended state is false
So my questions are:
Thank you in advance for your inputs
Upvotes: 1
Views: 867
Reputation: 55540
Yeah that is a bug in Apache Camel to not report the correct state - the route is really suspended. I have logged a ticket: https://issues.apache.org/jira/browse/CAMEL-8964
You can get the correct state using camelContext.getRouteStatus(routeId)
api.
Upvotes: 1