You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

CamelContext

The CamelContext represents a single Camel routing rulebase. You use the CamelContext in a similar way to the Spring ApplicationContext.

Lifecycle

The CamelContext provides methods to control its lifecycle:

  • start
  • stop
  • suspend Camel 2.5
  • resume Camel 2.5

The operations is 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 is given time to complete. If you start a CamelContext after a stop, then its performing a cold start, recreating all the state, cache etc. again.

Instead you can use the suspend/resume operations. They will keep the CamelContext warm and only suspend/stop routes using the same Graceful shutdown feature. This ensures messages is given time to complete.

End users is encouraged to use suspend/resume if you are temporary stopping a Camel application.

All these operations is available in JMX as well, so you can control Camel from a management console.

If you write unit tests and perform cold restarts using stop/start then any previously looked up Endpoints etc. is obsolete, and therefore you need to re-lookup those endpoints again.

Instead use suspend/resume which keeps these Endpoints and therefore you can still use them after resuming.

Service lifecycle

A service in Camel adheres to the following lifecycle states as illustrated in the diagram below:

See Also

  • No labels