Interface ShutdownPrepared

All Known Subinterfaces:
ShutdownAware

public interface ShutdownPrepared
Allows a Service to prepare for shutdown.

Important: Implementators of this interface must be a Service as well.

This allows Processors to prepare for shutdown, such as when CamelContext or a Route is shutting down. The Processor could be a stateful EIP such as the org.apache.camel.processor.aggregate.AggregateProcessor, allowing it to do custom work to prepare for shutdown.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    prepareShutdown(boolean suspendOnly, boolean forced)
    Prepares for stop/shutdown.
  • Method Details

    • prepareShutdown

      void prepareShutdown(boolean suspendOnly, boolean forced)
      Prepares for stop/shutdown.

      The ShutdownStrategy supports preparing for shutdown using two steps. First a regular preparation, where the given forced parameter will be false. And if the shutdown times out, then the ShutdownStrategy performs a more aggressive shutdown, calling this method a second time with true for the given forced parameter. For example by graceful stopping any threads or the likes.

      In addition a service can also be suspended (not stopped), and when this happens the parameter suspendOnly has the value true. This can be used to prepare the service for suspension, such as marking a worker thread to skip action.

      For forced shutdown, then the service is expected to aggressively shutdown any child services, such as thread pools etc. This is the last chance it has to perform such duties.

      Parameters:
      suspendOnly - true if the intention is to only suspend the service, and not stop/shutdown the service.
      forced - true is forcing a more aggressive shutdown, false is for preparing to shutdown.