IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > Adapter Toolkit > Implementing code from the IBM WebSphere Adapter Toolkit > Problem determination > Monitoring and measuring performance > Performance monitoring infrastructure (PMI) for resource adapters

Extend PMI on IBM BPM

To add a user-defined element or method into the list of monitorable components you need to modify code and schema files.


Purpose

  1. Monitorable Element Schema (.mes) file changes

    Defines the element type within an adapter where monitoring can be attached.

    The element type is specified using the Qname of the element type from the schema, which defines the structure of the artifact itself. It also defines the natures (ENTRY, EXIT, FAILURE) that are available for that type of element. The sample below declares how the monitors can be attached to myOutbound.

    For example myOutbound method can emit event at ENTRY, EXIT or FAILURE event points.

    <?xml version="1.0" encoding="UTF-8"?>
    <EventNaturesSpec
    	name="EventNatures"
    	targetNamespace=
      "http://www.ibm.com/xmlns/prod/websphere/scdl/eis/6.0.0:JCAAdapter"
    	xmlns=
      "http://www.ibm.com/xmlns/prod/websphere/monitoring/6.0.0/mes"
    	shortName="JCAAdapter">
    
      <Property>CEI</Property>
    	<ElementKind name="myOutbound">
    		<EventNature name="ENTRY" eventName="eis:WBI.JCAAdapter.myOutbound.ENTRY" />
    		<EventNature name="EXIT" eventName="eis:WBI.JCAAdapter.myOutbound.EXIT" />
    		<EventNature name="FAILURE" eventName="eis:WBI.JCAAdapter.myOutbound.FAILURE" />
    	</ElementKind>
  2. “.xsd” file changes

    The xsd event schema file provides monitoring specific of each data elements and it defines the types of events, payload or extended element for each event type that can be emitted for the data elements. Content of schema looks like following:

    <?xml version="1.0" encoding="UTF-8"?>
    <EventSpec xmlns=
     "http://www.ibm.com/xmlns/prod/websphere/monitoring/6.0.0/es"
    	name="Events"
        targetNamespace=
     "http://www.ibm.com/xmlns/prod/websphere/scdl/eis/6.0.0:JCAAdapter"
    	xmlns:er=
     "http://www.ibm.com/xmlns/prod/websphere/recovery/6.0.0/es/eventpayloads"
    >
    <complexType name="WBI.JCAAdapter.myOutbound.ENTRY">
    		<complexContent>
    			<extension base="wbi:WBIMonitoringEvent" />
    		</complexContent>
    	</complexType>
    
    	<complexType name="WBI.JCAAdapter.myOutbound.EXIT">
    		<complexContent>
    			<extension base="wbi:WBIMonitoringEvent" />
    		</complexContent>
    	</complexType>
    
    	<complexType name="WBI.JCAAdapter.myOutbound.FAILURE">
    	   <complexContent>
    			<extension base="wbi:WBIMonitoringEvent">
    				<sequence>
    					<element name="FailureReason" type="string" />
    				</sequence>			    
    			</extension>
    		</complexContent>
    	</complexType>
    
    </schema>

  3. Invoke PMI:

    To invoke PMI statistics around a method named myOutbound, you would do the following:

    1. Import com.ibm.j2ca.extension.monitoring.CEI.EventPoint;
    2. Define a unique PMI event point name.

      For example String eventName = uniqueAdapterID + “##” + "myOutbound";

    3. Get an instance of EventPoint:

      for each eventAction ENTRY, EXIT, FAILURE.

      EventPoint ep = (EventPoint)(EventPoints.INSTANCE.getEventPoints(eventName,eventAction))

    4. If eventPoint is enabled, then fire event for Entry, Exit and Failure is invoked.

      Entry event is fired in the beginning of the method call, exit event is fired in the end of the method call and failure event is fired in case of exception.

      For example we can invoke failure event by following API call.

      if(ep.isEnabled()) {
                ep.fire(new String[]{"FailureReason"}, 
                new Object[]{ex.toString()});} 

Performance monitoring infrastructure (PMI) for resource adapters