Using the BTM API

Add btmjeeapi.jar to your classpath if you have used the BTMMBeanConstants class in your application. See your operating system documentation for details.

The btmjeeapi.jar file is part of the development toolkit for the BTM API for Java EE. See Deploying the development toolkit.

import com.mqsoftware.BTM.mbean.BTMMBeanConstants;
* A Simple illustration of using the BTM API for JMX. This sample uses a minimal BTM model A minimum of Java 5.0 is required for the appropriate level of JMX runtime support.
* @author Copyright © BMCSoftware, Inc. All Rights Reserved.
public class BTMForJMXDemo {
private MBeanServer mbServer;
private ObjectName oName;
private static final String RESOURCE_1 = "Resource1";
private static final String RESOURCE_2 = "Resource2";
private static final String TXN_ID_PREFIX = "txnId";
public void main(String args[]) {
// Set up the arguments to pass to the MBean
Object[] arguments = new Object[BTMMBeanConstants.BTM_MONITOR_EX_API_SIGNATURE.length];
// Setup Transaction (payload) data.
// These three arrays must be of the same size.
// Only labels may contain nulls.
String[] tdn = { "PayloadName1", "PayloadName2" };
String[] tdv = { "value1", "value2" };
String[] tdl = { "label1", null };
// Populate the arguments with values.
// Most of the arguments are not used (set to null) in this example.
arguments[0] = "appName"; // Application Name
arguments[1] = "modelName"; // Model Name
arguments[2] = TXN_ID_PREFIX; // Transaction ID prefix
arguments[3] = null; // Instance ID
arguments[4] = RESOURCE_1; // Resource ID
arguments[5] = "success"; // Return Code
arguments[6] = null; // Destination IDs - Fan-out
arguments[7] = null; // Aliases
arguments[8] = tdn; // Transaction Data Names
arguments[9] = tdv; // Transaction Data Values
arguments[10] = tdl; // Transaction Data Labels
arguments[11] = null; // Timestamp - let the API set it's own.
try {
int txnNumber = 1;
mbServer = ManagementFactory.getPlatformMBeanServer();
* Construct the cannonical JMX name used for the BTM MBean. BTM
* MBeans must always use a cannonical name that matches the JMX
* Query used by the btmjee agent.
* ":,type=com.mqsoftware.BTM.mbean"
String name = ":mbeanIdentifier=" + BTMMBeanConstants.BTM_MBEAN_ID
+ ",name=BTMMBean,type=" + BTMMBeanConstants.BTM_MBEAN_TYPE;
System.out.println("Creating MBean using ObjectName: " + name);
// Instantiate the MBean in the MBean Server.
oName = new ObjectName(name);
mbServer.createMBean(BTMMBeanConstants.BTM_MBEAN_CLASSNAME, oName);
// Now loop, sending monitor information to BTM
while (true) {
String txnId = new String(TXN_ID_PREFIX + txnNumber);
arguments[2] = txnId;
// Set the first resource in model
arguments[4] = RESOURCE_1;
// Invoke the MBean monitor API
mbServer.invoke(oName, "monitorTransaction", arguments,
// Pause to give the transaction a duration
// Set the second resource in model
arguments[4] = RESOURCE_2;
// Invoke the MBean monitor API
mbServer.invoke(oName, "monitorTransaction", arguments,
System.out.println("Monitored transaction " + txnId);
} catch (Exception ex) {
System.out.println("An exception was encountered");

Was this page helpful? Yes No Submitting... Thank you