Java 类org.apache.camel.api.management.mbean.ManagedRouteMBean 实例源码

项目:Camel    文件:DefaultCamelContext.java   
public <T extends ManagedRouteMBean> T getManagedRoute(String routeId, Class<T> type) {
    // jmx must be enabled
    if (getManagementStrategy().getManagementAgent() == null) {
        return null;
    }

    Route route = getRoute(routeId);

    if (route != null) {
        try {
            ObjectName on = getManagementStrategy().getManagementNamingStrategy().getObjectNameForRoute(route);
            return getManagementStrategy().getManagementAgent().newProxyClient(on, type);
        } catch (MalformedObjectNameException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
    }

    return null;
}
项目:Camel    文件:ManagedRouteStopUsingMBeanAPITest.java   
public void testStopRoute() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }

    // fire a message to get it running
    getMockEndpoint("mock:result").expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();

    MBeanServer mbeanServer = getMBeanServer();

    Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
    assertEquals(1, set.size());

    ObjectName on = set.iterator().next();

    ManagedRouteMBean mbean = context.getManagementStrategy().getManagementAgent().newProxyClient(on, ManagedRouteMBean.class);

    // the route has this starting endpoint uri
    assertEquals("direct://start", mbean.getEndpointUri());

    // should be started
    assertEquals("Should be started", ServiceStatus.Started.name(), mbean.getState());

    mbean.stop();

    // should be stopped
    assertEquals("Should be stopped", ServiceStatus.Stopped.name(), mbean.getState());
}
项目:camelinaction2    文件:OldestTest.java   
@Test
public void testOldestReporter() throws Exception {
    getMockEndpoint("mock:done").expectedMessageCount(size);

    ManagedRouteMBean route = context.getManagedRoute("myRoute", ManagedRouteMBean.class);
    OldestDurationReporter reporter = new OldestDurationReporter(route);

    // schedule a background task that logs the current throttle count
    scheduler = context.getExecutorServiceManager().newSingleThreadScheduledExecutor(this, "OldestReporter");
    scheduler.scheduleAtFixedRate(reporter, 1, 1, TimeUnit.SECONDS);

    // send some orders
    for (int i = 0; i < size; i++) {
        template.sendBody("seda:foo", "Message " + i);
    }

    assertMockEndpointsSatisfied(1, TimeUnit.MINUTES);

    // just a little delay before running
    Thread.sleep(5000);

    resetMocks();
    getMockEndpoint("mock:done").expectedMessageCount(size);
    log.info("Running again a 2nd time");

    // send some orders
    for (int i = 0; i < size; i++) {
        template.sendBody("seda:foo", "2nd-Message " + i);
    }

    assertMockEndpointsSatisfied(1, TimeUnit.MINUTES);
    // shutdown thread pool
    context.getExecutorServiceManager().shutdown(scheduler);
}
项目:Camel    文件:CdiOsgiIT.java   
@Test
public void testExchangesCompleted() throws Exception {
    ManagedRouteMBean route = context.getManagedRoute(context.getRoute("consumer-route").getId(), ManagedRouteMBean.class);
    assertThat("Number of exchanges completed is incorrect!",
        route.getExchangesCompleted(), equalTo(1L));
}
项目:camelinaction2    文件:OldestDurationReporter.java   
public OldestDurationReporter(ManagedRouteMBean route) {
    this.route = route;
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public <T extends ManagedRouteMBean> T getManagedRoute(String routeId, Class<T> type) {
  return context.getManagedRoute(routeId, type);
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public <T extends ManagedRouteMBean> T getManagedRoute(String routeId, Class<T> type) {
    return context.getManagedRoute(routeId, type);
}
项目:camel-cdi    文件:HelloPaxExamTest.java   
@Test
public void test() throws Exception {
    assertThat("Number of routes is incorrect!", context.getRoutes().size(), is(equalTo(1)));
    ManagedRouteMBean route = context.getManagedRoute(context.getRoutes().get(0).getId(), ManagedRouteMBean.class);
    assertThat("Number of exchanges completed is incorrect!", route.getExchangesCompleted(), is(equalTo(1L)));
}
项目:Camel    文件:CamelContext.java   
/**
 * Gets the managed route client api with the given route id
 *
 * @param routeId id of the route
 * @param type the managed route type from the {@link org.apache.camel.api.management.mbean} package.
 * @return the route or <tt>null</tt> if not found
 * @throws IllegalArgumentException if the type is not compliant
 */
<T extends ManagedRouteMBean> T getManagedRoute(String routeId, Class<T> type);