use of org.apache.camel.Route in project camel by apache.
the class DefaultCamelContext method resumeRoute.
public synchronized void resumeRoute(String routeId) throws Exception {
if (!routeSupportsSuspension(routeId)) {
// start route if suspension is not supported
startRoute(routeId);
return;
}
RouteService routeService = routeServices.get(routeId);
if (routeService != null) {
resumeRouteService(routeService);
// must resume the route as well
Route route = getRoute(routeId);
ServiceHelper.resumeService(route);
}
}
use of org.apache.camel.Route 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.Route in project camel by apache.
the class DefaultCamelContext method suspendRouteService.
protected synchronized void suspendRouteService(RouteService routeService) throws Exception {
routeService.setRemovingRoutes(false);
routeService.suspend();
for (Route route : routeService.getRoutes()) {
logRouteState(route, "suspended");
}
}
use of org.apache.camel.Route 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();
}
}
}
use of org.apache.camel.Route in project camel by apache.
the class ManagedRestRegistryTest method testRestRegistry.
public void testRestRegistry() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=services,*");
// number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
ObjectName name = null;
for (ObjectName service : names) {
if (service.toString().contains("DefaultRestRegistry")) {
name = service;
break;
}
}
assertNotNull("Cannot find DefaultRestRegistry", name);
assertTrue(mbeanServer.isRegistered(name));
assertEquals(3, mbeanServer.getAttribute(name, "NumberOfRestServices"));
TabularData data = (TabularData) mbeanServer.invoke(name, "listRestServices", null, null);
assertEquals(3, data.size());
// should not be enabled as api-doc is not enabled or camel-swagger-java is not on classpath
String json = (String) mbeanServer.invoke(name, "apiDocAsJson", null, null);
assertNull(json);
// remove all routes
for (Route route : context.getRoutes()) {
context.stopRoute(route.getId());
context.removeRoute(route.getId());
}
assertEquals(0, mbeanServer.getAttribute(name, "NumberOfRestServices"));
data = (TabularData) mbeanServer.invoke(name, "listRestServices", null, null);
assertEquals(0, data.size());
}
Aggregations