Search in sources :

Example 26 with RouteStartupOrder

use of org.apache.camel.spi.RouteStartupOrder in project camel by apache.

the class DefaultShutdownStrategy method shutdownRoutesNow.

/**
     * Shutdown all the consumers immediately.
     *
     * @param routes the routes to shutdown
     */
protected void shutdownRoutesNow(List<RouteStartupOrder> routes) {
    for (RouteStartupOrder order : routes) {
        // set the route to shutdown as fast as possible by stopping after
        // it has completed its current task
        ShutdownRunningTask current = order.getRoute().getRouteContext().getShutdownRunningTask();
        if (current != ShutdownRunningTask.CompleteCurrentTaskOnly) {
            LOG.debug("Changing shutdownRunningTask from {} to " + ShutdownRunningTask.CompleteCurrentTaskOnly + " on route {} to shutdown faster", current, order.getRoute().getId());
            order.getRoute().getRouteContext().setShutdownRunningTask(ShutdownRunningTask.CompleteCurrentTaskOnly);
        }
        for (Consumer consumer : order.getInputs()) {
            shutdownNow(consumer);
        }
    }
}
Also used : ShutdownRunningTask(org.apache.camel.ShutdownRunningTask) Consumer(org.apache.camel.Consumer) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder)

Aggregations

RouteStartupOrder (org.apache.camel.spi.RouteStartupOrder)26 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)12 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)11 ArrayList (java.util.ArrayList)10 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)8 Route (org.apache.camel.Route)4 ShutdownRoute (org.apache.camel.ShutdownRoute)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Consumer (org.apache.camel.Consumer)3 SuspendableService (org.apache.camel.SuspendableService)3 LinkedHashSet (java.util.LinkedHashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Endpoint (org.apache.camel.Endpoint)2 PollingConsumer (org.apache.camel.PollingConsumer)2 Service (org.apache.camel.Service)2 LifecycleStrategy (org.apache.camel.spi.LifecycleStrategy)2