...
The best practice for stopping a route from a route, is to either
- signal to another thread to stop the route
- spin off a new thread to stop the route
Using another thread to stop the route is also what is normally used when stopping Camel itself, or for example when an application in a server is stopped etc. Its too tricky and hard to stop a route using the same thread that currently is processing a message from the route. This is not advised to do, and can cause unforeseen side effects.
...
And CamelContext also provides API for suspend/resume of routes, and shutdown as well.
- suspend/resume is faster than stop/start. For example a HTTP server will still run but deny any incoming requests.
Where as if it was stopped the HTTP listener would have been stopped. - shutdown means the route is being removed from CamelContext and cannot be started again. Its also removed from JMX.
A route must have been stopped prior to be shutdown.
See more details about the Lifecycle.
Tip |
---|
You can also use the ControlBus component to let it stop/start routes. |