Search in sources :

Example 6 with SuspendableService

use of org.apache.camel.SuspendableService in project camel by apache.

the class ManagedService method suspend.

public void suspend() throws Exception {
    if (!context.getStatus().isStarted()) {
        throw new IllegalArgumentException("CamelContext is not started");
    }
    if (service instanceof Suspendable && service instanceof SuspendableService) {
        SuspendableService ss = (SuspendableService) service;
        ss.suspend();
    } else {
        throw new UnsupportedOperationException("suspend() is not a supported operation");
    }
}
Also used : SuspendableService(org.apache.camel.SuspendableService) Suspendable(org.apache.camel.Suspendable)

Example 7 with SuspendableService

use of org.apache.camel.SuspendableService in project camel by apache.

the class ManagedService method resume.

public void resume() throws Exception {
    if (!context.getStatus().isStarted()) {
        throw new IllegalArgumentException("CamelContext is not started");
    }
    if (service instanceof SuspendableService) {
        SuspendableService ss = (SuspendableService) service;
        ss.resume();
    } else {
        throw new UnsupportedOperationException("resume() is not a supported operation");
    }
}
Also used : SuspendableService(org.apache.camel.SuspendableService)

Example 8 with SuspendableService

use of org.apache.camel.SuspendableService in project camel by apache.

the class DefaultCamelContext method suspendRoute.

public synchronized void suspendRoute(String routeId) throws Exception {
    if (!routeSupportsSuspension(routeId)) {
        // stop if we suspend is not supported
        stopRoute(routeId);
        return;
    }
    RouteService routeService = routeServices.get(routeId);
    if (routeService != null) {
        List<RouteStartupOrder> routes = new ArrayList<RouteStartupOrder>(1);
        Route route = routeService.getRoutes().iterator().next();
        RouteStartupOrder order = new DefaultRouteStartupOrder(1, route, routeService);
        routes.add(order);
        getShutdownStrategy().suspend(this, routes);
        // must suspend route service as well
        suspendRouteService(routeService);
        // must suspend the route as well
        if (route instanceof SuspendableService) {
            ((SuspendableService) route).suspend();
        }
    }
}
Also used : SuspendableService(org.apache.camel.SuspendableService) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) ShutdownRoute(org.apache.camel.ShutdownRoute) Route(org.apache.camel.Route)

Example 9 with SuspendableService

use of org.apache.camel.SuspendableService in project camel by apache.

the class DefaultCamelContext method suspendRoute.

public synchronized void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception {
    if (!routeSupportsSuspension(routeId)) {
        stopRoute(routeId, timeout, timeUnit);
        return;
    }
    RouteService routeService = routeServices.get(routeId);
    if (routeService != null) {
        List<RouteStartupOrder> routes = new ArrayList<RouteStartupOrder>(1);
        Route route = routeService.getRoutes().iterator().next();
        RouteStartupOrder order = new DefaultRouteStartupOrder(1, route, routeService);
        routes.add(order);
        getShutdownStrategy().suspend(this, routes, timeout, timeUnit);
        // must suspend route service as well
        suspendRouteService(routeService);
        // must suspend the route as well
        if (route instanceof SuspendableService) {
            ((SuspendableService) route).suspend();
        }
    }
}
Also used : SuspendableService(org.apache.camel.SuspendableService) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) RouteStartupOrder(org.apache.camel.spi.RouteStartupOrder) ShutdownRoute(org.apache.camel.ShutdownRoute) Route(org.apache.camel.Route)

Aggregations

SuspendableService (org.apache.camel.SuspendableService)9 Consumer (org.apache.camel.Consumer)3 Suspendable (org.apache.camel.Suspendable)3 ArrayList (java.util.ArrayList)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Route (org.apache.camel.Route)2 ShutdownRoute (org.apache.camel.ShutdownRoute)2 RouteBuilder (org.apache.camel.builder.RouteBuilder)2 RouteStartupOrder (org.apache.camel.spi.RouteStartupOrder)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PollingConsumer (org.apache.camel.PollingConsumer)1 StatefulService (org.apache.camel.StatefulService)1 QuartzComponent (org.apache.camel.component.quartz.QuartzComponent)1 QuartzComponent (org.apache.camel.component.quartz2.QuartzComponent)1