Versions Compared

Key

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

...

This option control how a given route consumer acts during shutdown. Most route consumer will only operate on a single task (message), however the Batch Consumer can operate on many messages (in a batch). This option is for those kind of consumers. By default it uses the option CompleteCurrentTaskOnly which mean that the current in progress task (message) will be completed and then the consumer will shutdown. The other option CompleteAllTasks allows the consumer to complete all the tasks (messages) before shutting down. For example a File consumer will process all the pending files it has picked up before shutting down.

TODO: example of this option in Java and Spring XML

A Java DSL based example to complete all messages during shutting down the first route:

Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java}

The same route in Spring XML would be:

Wiki Markup
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml}

JMX managed

The ShutdownStrategy is JMX aware as well so you can manage it from a JMX console. For example you can change the timeout value.

...

The method getPendingExchangesSize should return the number of pending messages which reside on the in memory queues.
The method deferShutdown should return false to defer the shutdown to very last when there are no more pending and inflight messages.

Batch Consumer should implement ShutdownAware so they properly supports the ShutdownRunningTask option. See for example GenericFileConsumer for an example.

See Also