THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
from("direct:start") .to("bean:foo?method=doSomething").routeId("myCoolRoute") .process(new Processor() { public void process(Exchange exchange) throws Exception { // remove myself from the in flight registry so we can stop this route without trouble context.getInflightRepository().remove(exchange); // stop this route context.stopRoute("myCoolRoute"); }); |
Important: It is not best practice to stop a route as shown above, as stopping a route using the same thread that routes messages can be tricky. Its better to spin off a separate thread that stops the route, or to use a boolean flag, and then flip the flag, from the route. And then have another process that monitors that flag, and reacts, to stop the route.
Camel provides another feature for managing routes at runtime which is RoutePolicy.
...