Start, stop, and review status of resource statistics collection in your CMP applications.
///////////////////////////////////////////////////////
// Sample CMP API code that connects to a local broker
// called 'testbrk' and writes out available
// resource types on the broker that have the
// ability to emit resource-level statistics.
BrokerProxy b = null;
try {
b = BrokerProxy.getLocalInstance("testbrk");
String[] resourceNames = b.getResourceTypeNames();
for (String thisResource : resourceNames) {
System.out.println(thisResource);
}
} catch (ConfigManagerProxyLoggedException e) {
e.printStackTrace();
} catch (ConfigManagerProxyPropertyNotInitializedException e) {
e.printStackTrace();
}
///////////////////////////////////////////////////////
// Sample CMP API code that connects to a local broker
// called 'testbrk' and writes out resource property
// names reported for a specific resource type.
BrokerProxy b = null;
try {
b = BrokerProxy.getLocalInstance("testbrk");
String[] resourcePropertyNames =
b.getResourceTypeStatisticsPropertyNames("JVM");
for (String thisResourceProperty : resourcePropertyNames) {
System.out.println(thisResourceProperty);
}
} catch (ConfigManagerProxyLoggedException e) {
e.printStackTrace();
} catch (ConfigManagerProxyPropertyNotInitializedException e) {
e.printStackTrace();
}
///////////////////////////////////////////////////////
// Sample CMP API code that connects to a local broker
// called 'testbrk' and gets a reference to the execution
// group called 'default'. It then enables resource
// statistics for all the integration server's resource types.
BrokerProxy b = null;
try {
b = BrokerProxy.getLocalInstance("testbrk");
ExecutionGroupProxy eg = b.getExecutionGroupByName("default");
if (eg != null) {
eg.setResourceStatisticsEnabled(null, true);
}
} catch (ConfigManagerProxyLoggedException e) {
e.printStackTrace();
} catch (ConfigManagerProxyPropertyNotInitializedException e) {
e.printStackTrace();
}
///////////////////////////////////////////////////////
// Sample CMP API code that connects to a local broker
// called 'testbrk' and gets a reference to the execution
// group called 'default'. It then disables resource
// statistics for all the integration server's resource types.
BrokerProxy b = null;
try {
b = BrokerProxy.getLocalInstance("testbrk");
ExecutionGroupProxy eg = b.getExecutionGroupByName("default");
if (eg != null) {
eg.setResourceStatisticsEnabled(null, false);
}
} catch (ConfigManagerProxyLoggedException e) {
e.printStackTrace();
} catch (ConfigManagerProxyPropertyNotInitializedException e) {
e.printStackTrace();
}
///////////////////////////////////////////////////////
// Sample CMP API code that connects to a local broker
// called 'testbrk' and gets a reference to the execution
// group called 'default'. It then writes out if resource
// statistics is enabled.
BrokerProxy b = null;
try {
b = BrokerProxy.getLocalInstance("testbrk");
ExecutionGroupProxy eg = b.getExecutionGroupByName("default");
if (eg != null) {
System.out.println(eg.getResourceStatisticsEnabled(null));
}
} catch (ConfigManagerProxyLoggedException e) {
e.printStackTrace();
} catch (ConfigManagerProxyPropertyNotInitializedException e) {
e.printStackTrace();
}