Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Build a CEI application for testing event selectors and event groups

Naveen Sachdeva (sachdeva@us.ibm.com), Advisory Software Engineer, IBM, Software Group
Naveen Sachdeva is an Advisory Software Engineer with the IBM Application Integration Middleware group. He has over 10 years of experience in large-scale systems integration and in the design and development of distributed computing systems. He currently helps IBM business partners with technical enablement and proof-of-concept using the WebSphere Studio family of products.

Summary:  Learn how to build a Common Event Infrastructure (CEI) -based application for testing event groups and event selectors. The author presents such an application, called EventTester, and shows you how this application uses the event access interface for querying historical events based on the specified event selector and event group. This paper shows you how to create event selectors for the Business Process Execution Language (BPEL) -based processes that are marked "Business Relevant."

Date:  31 Mar 2005
Level:  Intermediate
Also available in:   Japanese

Activity:  3617 views
Comments:  

Introduction

CEI provides an event access interface that you can use to query historical events. In order to query events, you need to specify an event group and, optionally, an event selector (see the sidebar Event selectors and event groups for more information). CEI includes an application -- CBEViewer -- that you can use to query events based on the specified event group. But before you can create an event group, you need to test the corresponding event selector. In addition, you might also want to test an event selector along with an event group before using such a combination in the code. This paper presents an application -- EventTester -- that you can use to test event selectors, event groups, and event groups with event selectors. It also shows you how to use this application in combination with the CBEViewer application to create event selectors.


Event Access interface

CEI supports a subset of XPath syntax to query events. You can query events using the Event Access interface, which the EventAccess session bean imiplements. You can create an instance of the EventAccess bean using the corresponding home interface, as Listing 1 shows.


Listing 1. Create an instance of EventAccess bean
// use home interface to create remote event access bean
InitialContext context = new InitialContext();
Object eventAccessHomeObj = 
context.lookup("ejb/com/ibm/events/access/EventAccess");
EventAccessHome eventAccessHome = (EventAccessHome)
  PortableRemoteObject.narrow(eventAccessHomeObj,
                              EventAccessHome.class);
eventAccess = (EventAccess) eventAccessHome.create();
			

Event selectors and event groups

An event selector is a regular expression that defines a set of events based on the property data (attributes or sub elements) of these events. For example, an event selector might specify all of the events from a particular host with a severity that is greater than 30 (warning). Because the CBE specification is based on XML, event selectors are written using a subset of the XPath syntax (for details on XPath restrictions refer to Information center for WebSphere Business Integration Server Foundation -- Writing event selectors in the Resources section).

The Event Access interface supports the following ways to query events:

  • Global instance identifier -- Get the event using its globalInstandId event property that can be used as a primary key.

CommonBaseEvent event = eventAccess.queryEventByGlobalInstanceId(eventId);

  • Event group -- Retrieve events that belong to a specified event group and (optionally) meet a criterion which is specified using an event selector. The ascendingOrder parameter is used to order events in either ascending or descending order according to creation time. The maxEvent parameter is used to specify the maximum number of events to be returned from the event query.

CommonBaseEvent[] events = eventAccess.queryEventsByEventGroup(eventGroup, eventSelector,

  • Association type -- Retrieve the associated events by associationType for a given event. An event can have other related or associated events. An association type attribute defines the relationship type such as: contains, cleared, causedBy, multiPart, or correlated.

CommonBaseEvent[] events = eventAccess.queryEventsByAssocation(associationType, eventId);


EventTester application

The EventTester application is an Event Access interface-based application that you can use to test event selectors and event groups. Complete code is available in the Download section (click the code icon at the top or bottom of this paper to download). Figure 1 shows the graphic user interface for the application. Given an event group and an event selector, this application returns the corresponding events. You can also test an event selector separately by using the default value for event group, or All events. Similarly, you can test an event group separately by using the default value for event selector, or CommonBaseEvent[@globalInstanceId]. The events are shown in a table format, with each row representing an event.


Figure 1. Event Tester application
Event Tester application

The application includes a Java Server Page (JSP) and a servlet. Listing 2 and Listing 3 (code listings appear in sidefiles) show the JSP and the servlet code for the application, respectively. The JSP provides the front-end for the application. When you click the Display Events button, it invokes the DisplayEvents servlet. This servlet uses the Event Access interface to query the events and forwards the result to the JSP. The JSP then formats the events and presents them to the user. In order to format the events, the JSP assumes that the events are CBE version 1.0.1 (for details on CBE, refer to Standardize messages with the Common Base Event model in the Resources section).


Using the EventTester application

You can use the EventTester application with or without the CBEViewer application. Since CBEViewer has a better user interface and filtering mechanism, I recommend using the EventTester application with the CBEViewer application. You can first use the CBEViewer to query all events (using the All Events event group) and understand the structure or pattern of the events in which you are interested, then create the corresponding XPath query and test it using the EventTester application.

For example, let?s say you have a process called MileStoneManager, which is marked as "BusinessRelevant;" in other words, it emits an event whenever it starts and stops, and you are interested in querying all the start and the corresponding stop events. In order to understand the structure of the events, you use the CBEViewer application. Figure 2 shows the required events in CBEViewer, and Figure 3 and Figure 4 show their details. From the start event details, you can see that the extensionName for the event is "WPC:ProcessInstanceEvent." It has an extendedDataElement called "processTemplateName" that shows that this event was emitted by MileStoneManager, and the categoryName for the situation is "StartSituation," which indicates that this event was emitted when process started. Similarly, from the stop event details, you can see that the extensionName for this event is also "WPC:ProcessInstanceEvent." It does not have any field that indicates that this event was emitted by MileStoneManager, but its contextDataElement is the same as the contextDataElement for the start event, and the categoryName for the situation is "StopSituation."


Figure 2. CBEViewer application
CBEViewer application

Below are the details of the MileStoneManager start event:

Table 1. MileStoneManager start event details

NameValue
version-1.0.1
globalInstanceIdCEC05DB5C52F6E90339824ECD0334F11D9
extensionNameWPC:ProcessInstanceEvent
localInstanceId
creationTime2004-11-10T19:34:53.213Z
severity10
msg
priority-
sequenceNumber1
repeatCount0
elapsedTime0
ContextDataElement: ECSCurrentID / contextValue_PI:10030100.23fb340d.ac3cd9f6.136200b8
ContextDataElement: ECSParentID / contextValue_PI:10030100.23fb33fe.ac3cd9f6.136200a6
ExtendedDataElement: UsernameUNAUTHENTICATED
ExtendedDataElement: processTemplateNameMileStoneManager
ExtendedDataElement: processTemplateId_PT:90010100.22fcafbd.ac3cd9f6.cfc80161
ExtendedDataElement: processInstanceId_PI:10030100.23fb340d.ac3cd9f6.136200b8
ExtendedDataElement: processInstanceExecutionState2 - STATE_RUNNING
ExtendedDataElement: processTemplateValidFromWed 2003-01-01 00:00:00.000
reporterComponentId
sourceComponentId / componentWBI-SF#Platform 5.1 [BASE 5.1.1 a0426.01] [JDK 1.4.1 ${build.level}] [PME 5.1.1 o0429.02]
sourceComponentId / subComponentWPC
sourceComponentId / componentIdTypeProductName
sourceComponentId / instanceIdlocalhost\localhost\server1
sourceComponentId / application
sourceComponentId / executionEnvironmentWindows 2000[x86]#5.0
sourceComponentId / locationnaveen.transarc.ibm.com
sourceComponentId / locationTypeHostname
sourceComponentId / processId1520
sourceComponentId / threadIdServlet.Engine.Transports : 0
sourceComponentId / componentTypehttp://www.ibm.com/namespaces/autonomic/Workflow_Engine
msgDataElement
situation / categoryNameStartSituation
situation / situationType / reasoningScopeEXTERNAL
situation / StartSituation / successDispositionSUCCESSFUL
situation / StartSituation / situationQualifierSTART_COMPLETED

The following table outlines the MileStoneManager stop event details:

Table 2. MileStoneManager stop event details

NameValue
version1.0.1
globalInstanceIdCEC05DB5C52F6E9033D38E4690334F11D9
extensionNameWPC:ProcessInstanceEvent
localInstanceId
creationTime2004-11-10T19:36:32.889Z
severity10
msg
priority-
sequenceNumber1
repeatCount0
elapsedTime0
ContextDataElement: ECSCurrentID / contextValue_PI:10030100.23fb340d.ac3cd9f6.136200b8
ContextDataElement: ECSParentID / contextValue_PI:10030100.23fb340d.ac3cd9f6.136200b8
ExtendedDataElement: WPCEventCode21004
ExtendedDataElement: processInstanceExecutionState3 - STATE_FINISHED
reporterComponentId
sourceComponentId / componentWBI-SF#Platform 5.1 [BASE 5.1.1 a0426.01] [JDK 1.4.1 ${build.level}] [PME 5.1.1 o0429.02]
sourceComponentId / subComponentWPC
sourceComponentId / componentIdTypeProductName
sourceComponentId / componentIdTypelocalhost\localhost\server1
sourceComponentId / application
sourceComponentId / executionEnvironmentWindows 2000[x86]#5.0
sourceComponentId / locationnaveen.transarc.ibm.com
sourceComponentId / locationTypeHostname
sourceComponentId / processId1520
sourceComponentId / threadIdServlet.Engine.Transports : 0
sourceComponentId / componentTypehttp://www.ibm.com/namespaces/autonomic/Workflow_Engine
msgDataElement
situation / categoryNameStopSituation
situation / situationType / reasoningScopeEXTERNAL
situation / StopSituation / successDispositionSUCCESSFUL
situation / StopSituation / situationQualifierSTOP_COMPLETED

Based on the start event details, you can create the following event selector to query all the MileStoneManager start events:

CommonBaseEvent[extensionName='WPC:ProcessInstanceEvent'] 
and extendedDataElement[name='processTemplateName' 
and type='string' and values='MileStoneManager'] 
and situation[categoryName='StartSituation']

You can test this event selector using the EventTester application, as Figure 3 shows. The page displays the details of the event based on the above event selector. Now that you have verified that the event selector works, you can create the corresponding event group -- MileStoneManagerStartEventGroup (for details on how to create event groups, refer to "On demand business process life cycle, Part 8: Business process monitoring -- Create key performance indicators" in the Resources section), and test it again using the EventTester application.


Figure 3. Testing the start event selector
Testing the start event selector

To query the stop event for a given start event, you can use the following event selector:

CommonBaseEvent[extensionName='WPC:ProcessInstanceEvent' 
and situation[categoryName='StopSituation'] 
and contextDataElements[name='ECSCurrentID' 
and type='ECSID' and values='<start event values>']]

where <start event values> ( such as PI:10030100.23fb340d.ac3cd9f6.136200b8) is specified at run-time.

Since event groups can only be created for static event selectors, you cannot create an event group corresponding to this event selector. But you can break this event selector into two event selectors, as shown below:

  1. CommonBaseEvent[extensionName='WPC:ProcessInstanceEvent' and situation[categoryName='StopSituation']]
  2. CommonBaseEvent[contextDataElements[name='ECSCurrentID' and type='ECSID' and values='<start event values>']]

Now you can create ProcessStopEventGroup, corresponding to the first event selector, and use it with the second event selector to query the appropriate stop event (for details on how to create event groups, refer to "On demand business process life cycle, Part 8: Business process monitoring -- Create key performance indicators" in the Resources section). But before you write the corresponding code, you can use the EventTester application to test this scenario as well, as Figure 4 shows.


Figure 4. Testing the stop event selector
Testing the stop event selector

Conclusion

In this paper, you learned how to build a Common Event Infrastructure (CEI) -based application for testing event groups and event selectors. You learned how this application uses the event access interface for querying historical events based on the specified event selector and event group amd how to use create event selectors for the processes that are marked as "Business Relevant."



Download

DescriptionNameSizeDownload method
Event tester WAR filews-ceicode.zip9 KB HTTP

Information about download methods


Resources

About the author

Naveen Sachdeva is an Advisory Software Engineer with the IBM Application Integration Middleware group. He has over 10 years of experience in large-scale systems integration and in the design and development of distributed computing systems. He currently helps IBM business partners with technical enablement and proof-of-concept using the WebSphere Studio family of products.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and Web services
ArticleID=57028
ArticleTitle=Build a CEI application for testing event selectors and event groups
publish-date=03312005
author1-email=sachdeva@us.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers