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

Common Event Infrastructure (CEI)

The Common Event Infrastructure (CEI) is a set of modular event processing components that provide functions to capture information about significant system or business occurrences.

IBM BPM includes the Common Event Infrastructure technology, which adapters use to create, transmit, persist, and distribute events.

If an adapter is running on a broker that does not use the IBM CEI technology but instead uses its own event monitoring technology; that broker can also plug-in its monitoring infrastructure with the adapters by implementing the interfaces described in the sections that follow and by optionally using schema definitions (.xsd and .mes files).


EventSourceContext

The EventSourceContext interface provides the context for a monitored component and is the starting point for the adapters. The EventSourceContext interface provides APIs to obtain event source, which is an application or component that submits an event creation request to CEI. Each event source defines a set of event points, which represent the points where CEI events are triggered.

/**
 * Provides the context for a monitored component.
 */

package com.ibm.j2ca.extension.monitoring.CEI;

public interface EventSourceContext
{
	/**
	  * Returns an event source for a monitored element.
	  * @param elementKind an artifact kind that can be 
			monitored e.g ResourceAdapter.
	  * @param elementName the name of the monitored element
	  * @return the event source object that encapsulates the 
			element to be monitored
	  */

    EventSource getEventSource(String elementKind, 
		String elementName);

	/**
	  * Creates an event source for a monitored element. 
		The usage is similar to 
   * java.util.logging.Logger.
	  * @param componentTypeQName : The element type can be 
		specified using the element 
   * type from 	  *  	a schema which defines the structure/syntax of the 
		artifact itself
	  *   	e.g.http://www.ibm.com/xmlns/prod/websphere/scdl/
				eis/6.0.0:JCAAdapter"
	  * @param componentQName  the name of the component , 	  *    	 e.g  http://www.ibm.com/j2ca/ResourceAdapter:Customer"
	  * @return the event source factory for the component 
		to be monitored
	  */

    public interface Factory{
    	EventSourceContext create(String componentTypeQName, 
		String componentQName);
    } }


EventSource

Event Sources are applications or components that submit event creation requests to CEI. Each monitorable element defines an event source. An example of event source is an adapter. An event source is used to retrieve event points in order to send monitoring events to a CEI logger.

package com.ibm.j2ca.extension.monitoring.CEI;

/**
 *      An event source represents a monitoarable element 
				kind such as an adapter....
 *      Each monitorable element defines an event source.  
				Each event source defines a set of component-element specific 
				event points.  An event source object is used 
 *      to retrieve event points to fire monitoring events 
 */
public interface EventSource 
{
     /**
     * returns an EventPoint for the monitored element
     * @param eventPointName a valid event nature for this event
     */
    public EventPoint getEventPoint(String eventPointName);}


EventPoint

Every monitorable component needs to define the event points. Each event point defines an event and the data or payload associated with that event. The EventPoint is used to fire monitoring events. The client of an event point needs to know the payload of the fired events. Where the payload of an event can be specified in an event catalog for each component.

package com.ibm.j2ca.extension.monitoring.CEI;
/**
 * Every monitorable component needs to defines the event points. 
 Each event point defines an event and the data/payload associated 
	with that event. The EventPoint is used to fire monitoring events.
 * The client of an event point needs to know the payload 
	of the fired events.
 */
public interface EventPoint
{
   /**
	*return the name of the event point 	*/

    String getName();

   /**
	* Checks if an event needs to be fired for this event point. 
		This method minimizes the overhead of inactive monitoring 	* points. 
 		Returns: true if this event point fires monitoring events.
    */

    boolean isEnabled();

   /**
	* Fires a monitoring event.
	* @param name  the name of the payload data element.
	* @param value the value of the payload data element
	*/

    void fire(String name, Object value);

   /**
    *  Fires a monitoring event,     *  it is a convenient method for payloads with two data elements.
*/

    void fire(String firstName, String secondName, Object firstValue, 
		Object secondValue);

	/**
     * Fires a monitoring event
     * It is a convenient method for payloads with 
			list of data elements.
     */
    void fire(String[] names, Object[] values);}


Unique Id

The Unique Id interface can be used to uniquely identify event points:

/**
 * Every monitorable component needs to defines the event points.  
 * Each event point defines  * an event and the data/payload associated with that event. 
	The EventPoint is 
 * used to fire monitoring events.
 * The client of an event point needs to know the payload 
		of the events.h
 */

public interface AdapterContext
{
	public String getUniqueId();
	}


Example of the schema definition files

  1. Monitorable element schema (.mes file):

    Monitorable element schema can be used to define element types that can be logged into the CEI database (Polling, InboundEventDelivery, Outbound etc) and it can also define natures that are available for each element type (entry, exit, failed, polling etc).

    <?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.1/mes"
    	xmlns:eis="http://www.ibm.com/xmlns/prod/websphere/scdl/eis/
    6.0.0:JCAAdapter" shortName="ResourceAdapter">
    
    	<Property>CEI</Property>
    <ElementKind name="Polling">
    		<EventNature name="STARTED" eventName=
    		"eis:WBI.JCAAdapter.Polling.STARTED" />
    		<EventNature name="STOPPED" eventName=
    		"eis:WBI.JCAAdapter.Polling.STOPPED" />
    	</ElementKind>
    </EventNaturesSpec>
  2. Xsd schema (.xsd):

    Xsd schema can be used to provide CEI specific to each data elements and it also defines the event types that can be emitted for the data elements.

    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
    	targetNamespace=
    	"http://www.ibm.com/xmlns/prod/websphere/scdl/eis/6.0.0:JCAAdapter"
    	xmlns:eis=
    	"http://www.ibm.com/xmlns/prod/websphere/scdl/eis/6.0.0:JCAAdapter"
    	xmlns:wbi=
    	"http://www.ibm.com/xmlns/prod/websphere/monitoring/6.1">
    	<import namespace="http://www.ibm.com/xmlns/prod/websphere/monitoring/
    6.1" schemaLocation="WBIEvent.xsd" />
    	<complexType name="WBI.JCAAdapter.Polling.STARTED">
    		<complexContent>
    			<extension base="wbi:WBIMonitoringEvent">
    				<sequence>
    					<element name="PollFrequency" type="int" minOccurs="1" maxOccurs="1" />
    					<element name="PollQuantity" type="int" minOccurs="1" maxOccurs="1" />
    				</sequence>
    			</extension>
    		</complexContent>
    	</complexType>
    
    	<complexType name="WBI.JCAAdapter.Polling.STOPPED">
    		<complexContent>
    			<extension base="wbi:WBIMonitoringEvent"></extension>
    		</complexContent>
    	</complexType>
    
    </schema>

Monitoring and measuring performance