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");
}
}
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");
}
}
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();
}
}
}
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();
}
}
}
Aggregations