Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It will output to log the progress during graceful shutdown as shown in an example below

Code Block

2009-12-20 10:56:53,055 [main           ] INFO  DefaultCamelContext            - Apache Camel  (CamelContext:camel-1) is stopping
2009-12-20 10:56:53,056 [main           ] INFO  DefaultShutdownStrategy        - Starting to graceful shutdown routes (timeout 300 seconds)
2009-12-20 10:56:53,059 [1: ShutdownTask] INFO  DefaultShutdownStrategy        - Waiting as there are still 5 inflight exchanges to complete before we can shutdown
2009-12-20 10:56:54,060 [1: ShutdownTask] INFO  DefaultShutdownStrategy        - Waiting as there are still 4 inflight exchanges to complete before we can shutdown
2009-12-20 10:56:55,061 [1: ShutdownTask] INFO  DefaultShutdownStrategy        - Waiting as there are still 3 inflight exchanges to complete before we can shutdown
2009-12-20 10:56:56,065 [1: ShutdownTask] INFO  DefaultShutdownStrategy        - Waiting as there are still 2 inflight exchanges to complete before we can shutdown
2009-12-20 10:56:57,066 [1: ShutdownTask] INFO  DefaultShutdownStrategy        - Waiting as there are still 1 inflight exchanges to complete before we can shutdown
2009-12-20 10:56:58,069 [main           ] INFO  DefaultShutdownStrategy        - Graceful shutdown of routes complete in 5 seconds.
2009-12-20 10:56:58,072 [main           ] INFO  DefaultInflightRepository      - Shutting down with no inflight exchanges.
2009-12-20 10:56:58,077 [main           ] INFO  DefaultCamelContext            - Apache Camel  (CamelContext:camel-1) stopped

...

If you do not want to see these logs, you can suppress this by setting the option SuppressLoggingOnTimeout to true.

Code Block

context.getShutdownStrategegy().setSuppressLoggingOnTimeout(true);

Notice the suppress is a "best effort" though there may still be some logs coming from 3rd party libraries and whatnot, which Camel cannot control.

Logging inflight exchange information on timeout

Available as of Camel 2.15

If a graceful shutdown could not shutdown cleanly within the given timeout period, then Camel performs a more aggressive shutdown by forcing routes and thread pools etc to shutdown. When the timeout happens, then Camel logs information about the current inflight exchanges, which shows from which route the exchange origins, and where it currently is being routed. For example the logging below, shows that there is 1 inflight exchange, that origins from route1, and currently is still in route1 at the "delay1" node. The elapsed is time in millis how long at the current node (eg delay1) and duration is total time in mills.

If you enable DEBUG logging level on org.apache.camel.impl.DefaultShutdownStrategy then it logs the same inflight exchange information during graceful shutdown

Code Block
2015-01-12 13:23:23,656 [ - ShutdownTask] INFO DefaultShutdownStrategy        - There are 1 inflight exchanges:
	InflightExchange: [exchangeId=ID-davsclaus-air-62213-1421065401253-0-3, fromRouteId=route1, routeId=route1, nodeId=delay1, elapsed=2007, duration=2017]

If you do not want to see these logs, you can turn this off by setting the option logInflightExchangesOnTimeout to false.

Code Block
context.getShutdownStrategegy().setLogInflightExchangesOnTimeout(false);

Controlling ordering of routes

...