Search in sources :

Example 71 with Route

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);
    }
}
Also used : ShutdownRoute(org.apache.camel.ShutdownRoute) Route(org.apache.camel.Route)

Example 72 with 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();
        }
    }
}
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 73 with Route

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");
    }
}
Also used : ShutdownRoute(org.apache.camel.ShutdownRoute) Route(org.apache.camel.Route)

Example 74 with Route

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();
        }
    }
}
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 75 with Route

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());
}
Also used : Route(org.apache.camel.Route) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) TabularData(javax.management.openmbean.TabularData)

Aggregations

Route (org.apache.camel.Route)90 EventDrivenConsumerRoute (org.apache.camel.impl.EventDrivenConsumerRoute)27 Endpoint (org.apache.camel.Endpoint)24 Channel (org.apache.camel.Channel)17 DeadLetterChannel (org.apache.camel.processor.DeadLetterChannel)15 Processor (org.apache.camel.Processor)13 ArrayList (java.util.ArrayList)12 SendProcessor (org.apache.camel.processor.SendProcessor)11 CamelContext (org.apache.camel.CamelContext)10 ShutdownRoute (org.apache.camel.ShutdownRoute)8 FilterProcessor (org.apache.camel.processor.FilterProcessor)7 RoutePolicy (org.apache.camel.spi.RoutePolicy)6 HashMap (java.util.HashMap)5 Service (org.apache.camel.Service)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 DelegateProcessor (org.apache.camel.DelegateProcessor)4 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)4 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)4