org.apache.camel.spi
Interface ShutdownAware

All Known Implementing Classes:
DirectConsumer, FileConsumer, FtpConsumer, GenericFileConsumer, IBatisConsumer, JpaConsumer, KestrelConsumer, MailConsumer, MyBatisConsumer, RemoteFileConsumer, RouteboxDirectConsumer, RouteboxSedaConsumer, S3Consumer, SedaConsumer, SftpConsumer, SqsConsumer

public interface ShutdownAware

Allows Consumer to fine grained control on shutdown which mostly have to cater for in-memory based components. These components need to be able to have an extra chance to have their pending exchanges being completed to support graceful shutdown. This helps ensure that no messages get lost.

Version:
See Also:
ShutdownStrategy

Method Summary
 boolean deferShutdown(ShutdownRunningTask shutdownRunningTask)
          To defer shutdown during first phase of shutdown.
 int getPendingExchangesSize()
          Gets the number of pending exchanges.
 void prepareShutdown()
          Prepares the consumer for shutdown.
 

Method Detail

deferShutdown

boolean deferShutdown(ShutdownRunningTask shutdownRunningTask)
To defer shutdown during first phase of shutdown. This allows any pending exchanges to be completed and therefore ensure a graceful shutdown without loosing messages. At the very end when there are no more inflight and pending messages the consumer could then safely be shutdown.

This is needed by SedaConsumer.

Parameters:
shutdownRunningTask - the configured option for how to act when shutting down running tasks.
Returns:
true to defer shutdown to very last.

getPendingExchangesSize

int getPendingExchangesSize()
Gets the number of pending exchanges.

Some consumers has internal queues with Exchange which are pending. For example the SedaConsumer.

Return zero to indicate no pending exchanges and therefore ready to shutdown.

Returns:
number of pending exchanges

prepareShutdown

void prepareShutdown()
Prepares the consumer for shutdown.

For example by graceful stopping any threads or the likes.



Apache CAMEL