use of javax.management.MBeanServer in project camel by apache.
the class ManagedThrottlerTest method testRejectedExecutionCallerRuns.
public void testRejectedExecutionCallerRuns() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName throttlerName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mythrottler2\"");
// use route to get the total time
ObjectName routeName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=routes,name=\"route2\"");
// reset the counters
mbeanServer.invoke(routeName, "reset", null, null);
MockEndpoint mock = getMockEndpoint("mock:endAsyncRejectCallerRuns");
// only one message (the first one) should get through because the rest should get delayed
mock.expectedMessageCount(10);
MockEndpoint exceptionMock = getMockEndpoint("mock:rejectedExceptionEndpoint");
exceptionMock.expectedMessageCount(0);
for (int i = 0; i < 10; i++) {
template.sendBody("seda:throttleCountRejectExecutionCallerRuns", "Message " + i);
}
assertMockEndpointsSatisfied();
}
use of javax.management.MBeanServer in project camel by apache.
the class ManagedThrottlerTest method testThrottleVisableViaJmx.
public void testThrottleVisableViaJmx() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
if (isPlatform("windows")) {
// windows needs more sleep to read updated jmx values so we skip as we dont want further delays in core tests
return;
}
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName throttlerName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mythrottler2\"");
// use route to get the total time
ObjectName routeName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=routes,name=\"route2\"");
// reset the counters
mbeanServer.invoke(routeName, "reset", null, null);
getMockEndpoint("mock:end").expectedMessageCount(10);
NotifyBuilder notifier = new NotifyBuilder(context).from("seda:throttleCount").whenReceived(5).create();
for (int i = 0; i < 10; i++) {
template.sendBody("seda:throttleCount", "Message " + i);
}
assertTrue(notifier.matches(2, TimeUnit.SECONDS));
assertMockEndpointsSatisfied();
Long completed = (Long) mbeanServer.getAttribute(routeName, "ExchangesCompleted");
assertEquals(10, completed.longValue());
}
use of javax.management.MBeanServer in project camel by apache.
the class ManagedThrottlerTest method testRejectedExecution.
public void testRejectedExecution() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName throttlerName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mythrottler2\"");
// use route to get the total time
ObjectName routeName = ObjectName.getInstance("org.apache.camel:context=camel-1,type=routes,name=\"route2\"");
// reset the counters
mbeanServer.invoke(routeName, "reset", null, null);
MockEndpoint mock = getMockEndpoint("mock:endAsyncReject");
// only one message (the first one) should get through because the rest should get delayed
mock.expectedMessageCount(1);
MockEndpoint exceptionMock = getMockEndpoint("mock:rejectedExceptionEndpoint1");
exceptionMock.expectedMessageCount(9);
for (int i = 0; i < 10; i++) {
template.sendBody("seda:throttleCountRejectExecution", "Message " + i);
}
assertMockEndpointsSatisfied();
}
use of javax.management.MBeanServer in project camel by apache.
the class ManagedThrottlingInflightRoutePolicyTest method testRoutes.
public void testRoutes() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(1, set.size());
ObjectName on = set.iterator().next();
boolean registered = mbeanServer.isRegistered(on);
assertEquals("Should be registered", true, registered);
String uri = (String) mbeanServer.getAttribute(on, "EndpointUri");
// the route has this starting endpoint uri
assertEquals("direct://start", uri);
Integer val = (Integer) mbeanServer.getAttribute(on, "InflightExchanges");
// the route has no inflight exchanges
assertEquals(0, val.intValue());
// should be started
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be started", ServiceStatus.Started.name(), state);
// should have route policy
String policy = (String) mbeanServer.getAttribute(on, "RoutePolicyList");
assertNotNull(policy);
assertTrue("Should be a throttling, was: " + policy, policy.startsWith("ThrottlingInflightRoutePolicy"));
}
use of javax.management.MBeanServer in project camel by apache.
the class ManagedTopicLoadBalancerTest method testManageTopicLoadBalancer.
public void testManageTopicLoadBalancer() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
// get the stats for the route
MBeanServer mbeanServer = getMBeanServer();
// get the object name for the delayer
ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"mysend\"");
// should be on route1
String routeId = (String) mbeanServer.getAttribute(on, "RouteId");
assertEquals("route1", routeId);
String camelId = (String) mbeanServer.getAttribute(on, "CamelId");
assertEquals("camel-1", camelId);
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals(ServiceStatus.Started.name(), state);
Integer size = (Integer) mbeanServer.getAttribute(on, "Size");
assertEquals(2, size.intValue());
TabularData data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { false }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(2, data.size());
data = (TabularData) mbeanServer.invoke(on, "explain", new Object[] { true }, new String[] { "boolean" });
assertNotNull(data);
assertEquals(5, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Balances message processing among a number of nodes"));
}
Aggregations