public interface ShutdownStrategy extends StaticService
RouteController
via CamelContext
.
The key problem is to stop the input consumers for the routes such that no new messages is coming into Camel. But at
the same time still keep the routes running so the existing in flight exchanges can still be run to completion. On
top of that there are some in memory components (such as SEDA) which may have pending messages on its in memory queue
which we want to run to completion as well, otherwise they will get lost.
Camel provides a default strategy which supports all that that can be used as inspiration for your own strategy.ShutdownAware
,
RouteController
Modifier and Type | Method and Description |
---|---|
boolean |
forceShutdown(Service service)
Whether a service is forced to shutdown.
|
long |
getTimeout()
Gets the timeout.
|
TimeUnit |
getTimeUnit()
Gets the time unit used
|
boolean |
hasTimeoutOccurred()
Whether a timeout has occurred during a shutdown.
|
boolean |
isLogInflightExchangesOnTimeout()
Whether to log information about the inflight
Exchange s which are still running during a
shutdown which didn't complete without the given timeout. |
boolean |
isShutdownNowOnTimeout()
Whether to force shutdown of all consumers when a timeout occurred.
|
boolean |
isShutdownRoutesInReverseOrder()
Whether to shutdown routes in reverse order than they where started.
|
boolean |
isSuppressLoggingOnTimeout()
Whether Camel should try to suppress logging during shutdown and timeout was triggered, meaning forced shutdown
is happening.
|
void |
setLogInflightExchangesOnTimeout(boolean logInflightExchangesOnTimeout)
Sets whether to log information about the inflight
Exchange s which are still running
during a shutdown which didn't complete without the given timeout. |
void |
setShutdownNowOnTimeout(boolean shutdownNowOnTimeout)
Sets whether to force shutdown of all consumers when a timeout occurred and thus not all consumers was shutdown
within that period.
|
void |
setShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder)
Sets whether routes should be shutdown in reverse or the same order as they where started.
|
void |
setSuppressLoggingOnTimeout(boolean suppressLoggingOnTimeout)
Whether Camel should try to suppress logging during shutdown and timeout was triggered, meaning forced shutdown
is happening.
|
void |
setTimeout(long timeout)
Set an timeout to wait for the shutdown to complete.
|
void |
setTimeUnit(TimeUnit timeUnit)
Set the time unit to use
|
void |
shutdown(CamelContext context,
List<RouteStartupOrder> routes)
Shutdown the routes
|
void |
shutdown(CamelContext context,
List<RouteStartupOrder> routes,
long timeout,
TimeUnit timeUnit)
Shutdown the routes using a specified timeout instead of the default timeout values
|
boolean |
shutdown(CamelContext context,
RouteStartupOrder route,
long timeout,
TimeUnit timeUnit,
boolean abortAfterTimeout)
Shutdown the route using a specified timeout instead of the default timeout values and supports abortAfterTimeout
mode
|
void |
shutdownForced(CamelContext context,
List<RouteStartupOrder> routes)
Shutdown the routes, forcing shutdown being more aggressive, if timeout occurred.
|
void |
suspend(CamelContext context,
List<RouteStartupOrder> routes)
Suspends the routes
|
void |
suspend(CamelContext context,
List<RouteStartupOrder> routes,
long timeout,
TimeUnit timeUnit)
Suspends the routes using a specified timeout instead of the default timeout values
|
void shutdownForced(CamelContext context, List<RouteStartupOrder> routes) throws Exception
CamelContext
is shutting down, to ensure Camel will shutdown if messages
seems to be stuck.context
- the camel contextroutes
- the routes, ordered by the order they was startedException
- is thrown if error shutting down the consumers, however its preferred to avoid thisvoid shutdown(CamelContext context, List<RouteStartupOrder> routes) throws Exception
context
- the camel contextroutes
- the routes, ordered by the order they was startedException
- is thrown if error shutting down the consumers, however its preferred to avoid thisvoid suspend(CamelContext context, List<RouteStartupOrder> routes) throws Exception
context
- the camel contextroutes
- the routes, ordered by the order they was startedException
- is thrown if error suspending the consumers, however its preferred to avoid thisvoid shutdown(CamelContext context, List<RouteStartupOrder> routes, long timeout, TimeUnit timeUnit) throws Exception
context
- the camel contextroutes
- the routes, ordered by the order they was startedtimeout
- timeouttimeUnit
- the unit to useException
- is thrown if error shutting down the consumers, however its preferred to avoid thisboolean shutdown(CamelContext context, RouteStartupOrder route, long timeout, TimeUnit timeUnit, boolean abortAfterTimeout) throws Exception
context
- the camel contextroute
- the routetimeout
- timeouttimeUnit
- the unit to useabortAfterTimeout
- should abort shutdown after timeoutException
- is thrown if error shutting down the consumer, however its preferred to avoid thisvoid suspend(CamelContext context, List<RouteStartupOrder> routes, long timeout, TimeUnit timeUnit) throws Exception
context
- the camel contextroutes
- the routes, ordered by the order they was startedtimeout
- timeouttimeUnit
- the unit to useException
- is thrown if error suspending the consumers, however its preferred to avoid thisvoid setTimeout(long timeout)
Long.MAX_VALUE
The default timeout unit is SECONDStimeout
- timeoutIllegalArgumentException
- if the timeout value is 0 or negativelong getTimeout()
void setTimeUnit(TimeUnit timeUnit)
timeUnit
- the unit to useTimeUnit getTimeUnit()
void setSuppressLoggingOnTimeout(boolean suppressLoggingOnTimeout)
suppressLoggingOnTimeout
- true to suppress logging, false to log as usual.boolean isSuppressLoggingOnTimeout()
void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout)
CamelContext
has been shutdown.shutdownNowOnTimeout
- true to force shutdown, false to leave them runningboolean isShutdownNowOnTimeout()
void setShutdownRoutesInReverseOrder(boolean shutdownRoutesInReverseOrder)
shutdownRoutesInReverseOrder
- true to shutdown in reverse orderboolean isShutdownRoutesInReverseOrder()
void setLogInflightExchangesOnTimeout(boolean logInflightExchangesOnTimeout)
Exchange
s which are still running
during a shutdown which didn't complete without the given timeout.logInflightExchangesOnTimeout
- true to log information about the inflight exchanges,
false to not logboolean isLogInflightExchangesOnTimeout()
Exchange
s which are still running during a
shutdown which didn't complete without the given timeout.boolean forceShutdown(Service service)
org.apache.camel.processor.RedeliveryErrorHandler
uses this information to know if
a forced shutdown is in progress, and then break out of redelivery attempts.service
- the serviceboolean hasTimeoutOccurred()
Apache Camel