use of javax.management.ObjectName in project camel by apache.
the class ManagedLoopTest method testManageLoop.
public void testManageLoop() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MockEndpoint foo = getMockEndpoint("mock:foo");
foo.expectedMessageCount(2);
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "2");
assertMockEndpointsSatisfied();
// 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);
String lan = (String) mbeanServer.getAttribute(on, "ExpressionLanguage");
assertEquals("header", lan);
String uri = (String) mbeanServer.getAttribute(on, "Expression");
assertEquals("foo", uri);
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(6, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Processes a message multiple times"));
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedMarshalTest method testManageMarshal.
public void testManageMarshal() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MockEndpoint foo = getMockEndpoint("mock:foo");
foo.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", "Hello World", "foo", "123");
assertMockEndpointsSatisfied();
// 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);
String name = (String) mbeanServer.getAttribute(on, "DataFormatName");
assertEquals("string", name);
String xml = (String) mbeanServer.invoke(on, "dumpProcessorAsXml", null, null);
assertTrue(xml.contains("<marshal"));
assertTrue(xml.contains("</marshal>"));
assertTrue(xml.contains("<string charset=\"iso-8859-1\"/>"));
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(4, data.size());
String json = (String) mbeanServer.invoke(on, "informationJson", null, null);
assertNotNull(json);
assertTrue(json.contains("\"description\": \"Marshals data into a specified format for transmission over a transport or component"));
}
use of javax.management.ObjectName in project camel by apache.
the class ManagedNamePatternFixedTest method testManagedNamePattern.
public void testManagedNamePattern() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
assertEquals("cool", context.getManagementName());
ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + context.getManagementName() + ",type=context,name=\"camel-1\"");
assertTrue("Should be registered", mbeanServer.isRegistered(on));
}
use of javax.management.ObjectName in project camel by apache.
the class DefaultCamelContext method getManagedProcessor.
public <T extends ManagedProcessorMBean> T getManagedProcessor(String id, Class<T> type) {
// jmx must be enabled
if (getManagementStrategy().getManagementAgent() == null) {
return null;
}
Processor processor = getProcessor(id);
ProcessorDefinition def = getProcessorDefinition(id);
if (processor != null && def != null) {
try {
ObjectName on = getManagementStrategy().getManagementNamingStrategy().getObjectNameForProcessor(this, processor, def);
return getManagementStrategy().getManagementAgent().newProxyClient(on, type);
} catch (MalformedObjectNameException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
}
return null;
}
use of javax.management.ObjectName in project camel by apache.
the class TestSupportJmxCleanup method traceMBeans.
// useful helper to invoke in TestSupport to figure out what test leave junk behind
public static void traceMBeans(String domain) throws Exception {
MBeanServer mbsc = ManagementFactory.getPlatformMBeanServer();
String d = getDomainName(domain);
Set<ObjectName> s = mbsc.queryNames(new ObjectName(d + ":*"), null);
if (s.size() > 0) {
LOG.warn(" + " + s.size() + " ObjectNames registered in domain \"" + d + "\"");
for (ObjectName on : s) {
LOG.warn(" | " + on);
}
}
}
Aggregations