Camel uses a simple lifecycle interface called Service which has
Many of Camel’s classes implement
Service such as
CamelContext along with all
When you use Camel you typically have to start the
CamelContext which will start all the various components and endpoints and activate the routing rules until the context is stopped again.
CamelContext provides methods to control its lifecycle:
The operations are paired: start/stop and suspend/resume.
Stop is performing a Graceful Shutdown which means all its internal state, cache, etc is cleared; and the routes is being stopped in a graceful manner to ensure messages are given time to complete.
| If you start a |
End users is encouraged to use suspend/resume if you are temporary stopping a Camel application.
All these operations are available in JMX as well, so you can control Camel from JMX management.
A service (
org.apache.camel.Service) in Camel adheres to the following lifecycle states as illustrated in the diagram below:
org.apache.camel.support.service.ServiceSupport is a good base class to extend for custom services as it offers the basic functionally to keep track of state. You implement your custom logic in the
| A service can optimally support suspend/resume by the |