WebSphere® Integration Developer and WebSphere Process Server introduced Common Event Infrastructure (CEI) as a way of providing basic event management services. CEI processes Common Base Events (CBEs) as defined by the CBE specifications. CEI provides a standard XML-based format for events, which enables generic mechanisms to both log and query events. Built-in support for CEI in WebSphere Integration Developer generates CBE events. For example, you can select a Business Process Execution Language (BPEL) activity and then select activity-started or activity-stopped events, which automatically generate CBEs. However, you might need to generate business-level events that do not correspond to WebSphere Integration Developer events. You can use the Business Process Engine (BPE) API for this. However, because this API exposes the CBE format as well as other CEI-specific attributes, the relevant parts of the API are contained in an easy-to-use set of artifacts that support logging, querying, and viewing events. This article explains these artifacts and how to use them in a composite application.
Capturing business-level events
In order to measure a composite application, you need to capture business-level events. Business-level events are events that capture information relevant to a business. For example, an event is logged when bank funds transfer from one account to another. Business-level events help us understand and improve how an enterprise does business. After business events are logged, you can aggregate them to identify business trends, which, in turn, can provide the needed measurement to improve the business. However, business-level events do not necessarily correlate to any specific WebSphere Integration Developer activity. A WebSphere Integration activity can correspond to a series of WebSphere Integration Developer steps. Figure 2 shows some typical WebSphere Integration Developer activities. A business-level event can correspond to a series of WebSphere Integration Developer activities.
Another requirement to be fully measurable is the capability to persist arbitrary data in an event. This arbitrary data has meaning at a business level. The CBE specification supports persisting arbitrary data using the ExtendedDataElement section of the CBE. This section formats application-specific data as a set of name value pairs.
Each type of monitorable component, such as business processes, business rules, and so on, has a set of predefined business events in WebSphere Integration Developer (see Table 1). However, sometimes these predefined events do not provide the flexibility to generate business-level events. Therefore, to provide your composite application with the capability to be fully measurable, you need to generate business-level events any time.
Table 1. Monitorable elements for each editor
| Editor | Monitorable element |
|---|---|
| Assembly editor (CEI only) | Operation |
| Business process editor (CEI and Audit Log) | Assign, Compensate, Empty, Flow (Parallel Activities), Invoke, Pick (Receive Choice), Process, Receive, Reply, Rethrow, Scope, Script, Sequence, Staff, Switch (Choice), Template (not shown), Terminate, Throw, Variable, Wait, While (While loop) |
| Business object-mapping editor (CEI only) | Map, Transformation (all kinds) |
| Business rule-group editor (CEI only) | Operation |
| Business state machine editor (CEI only) | Action, Entry, Exit, Guard, State, State Machine Definition (State Machine), Timer, Transition |
| Human task editor (CEI and Audit Log) | Escalation, Task, Task Template (not shown) |
| Interface-mapping editor (CEI only) | Operation Binding, Parameter mediation (all kinds) |
| Selector editor (CEI only) | Operation |
Note: In Table 1, the events identified as Audit Log are generated as audit events in the process choreographer database. The events identified as CEI are generated in the CEI data store.
Table 2. Activities and their associated default events
| Activity | Default event name |
|---|---|
| Invoke | Completion forced, Entry, Exit, Expired, Failed, Retry forced, Skipped, Stopped, Terminated |
| Process | Compensated, Compensating, Compensation failed, Correlation, Deleted, Entry, Event handler escalated, Event received, Exit, Failed, Failing, Restarted, Resumed, Suspended, Terminated, Terminating, Work item created, Work item deleted, Work item transferred |
| Receive | Entry, Exit, Terminated |
| Reply | Exit, Failed, Skipped |
| Scope | Compensated, Compensating, Compensation failed, Entry, Event handler escalated, Event received, Exit, Failed, Failing, Skipped, Terminated |
| Staff | Assigned, Completion forced, Created, Deassigned, Escalated, Exit, Expired, Failed, Fault set, Output set, Retry forced, Skipped, Stopped, Terminated, Work item created, Work item deleted, Work item refreshed, Work item transferred |
| Template (not shown) | Deleted, Entry |
There are two options available to retrieve and analyze CBEs.
- The CBE Event Browser, which WebSphere Process Server provides, offers a simple view of CBEs and can be launched in WebSphere Integration Developer from the server view or from a browser at http://localhost:9060/ibm/console/cbebrowser. This option is useful for developers who want to view generated events (see Figure 1).
- You can use a program to retrieve events and perform custom analysis and presentation. The artifacts address this option.
Figure 1. CBE Event Browser

In order to process business-level events, see Downloads for three generic artifacts. Business-level events can be emitted with the CEIEventEmitter, queried with the CEIQueryService, or viewed with the CEIMeteringViewPortlet.
The CEIEventEmitter (see Figure 2) allows us to generate business-level events from either a Java™ snippet or as a Service Component Architecture (SCA) component invoked from a business process. The event can be correlated to a business-level event, and it can contain an arbitrary set of name value pairs.
Figure 2. Class diagram of CEIEventEmitter

Emitting an event from Java code
Listing 1 shows an example of emitting a business-level event from Java code. You can use a Factory Pattern to create the event emitter and then invoke it with the appropriate data. You can either generate a log event (emitLogMessage) that contains a simple message or a standard event (emitEvent) that contains an eventName, an eventTrackingId, and a set of name value pairs containing the data for the event.
Listing 1. Java snippet
ICEIEventEmitter eventEmitter = CEIEventManagementFactory.createEventEmitter();
eventEmitter.emitLogMessage(String application, String eventTrackingId, String message);
eventEmitter.emitEvent(String application, String eventTrackingId, String event,
String[] eventDataName, String[] eventDataValue)
throws CEIEventException; |
An eventTrackingId correlates all related events. For example, you might use the same eventTrackingId for one business process. The event is a string that identifies the business-level event that has occurred. You can use colons to create semantically meaningful event names, such as WPS:BusinessLevelEvent:FundTransferEvent.
Listing 2 is an example code snippet used in a banking application to log a business-level event during an account transfer.
Listing 2. Banking application example using CEIEventEmitter
// Bean implementation class for Enterprise Bean: AccountTransferService
public class AccountTransferServiceBean implements javax.ejb.SessionBean {
//some code is ignored here
public void makeTransfer( String bankId, String fromAccId, String toAccId,
BigDecimal amount, String description)
throws EJBException, TransferException {
// some code is ignored here
try {
fromTransaction = transactionsLocalHome.create(time.toString(),
fromAccId,fromBankId,"Transfer",time);
fromTransaction.setDescription(description);
fromTransaction.setTotal(amount);
fromTransaction.setToaccid(toAccId);
} catch (CreateException e2) { e2.printStackTrace();}
meterDebitEvent(fromBankId,fromAccount.getCustomerid(),fromAccId,amount);
meterCreditEvent(toBankId,toAccount.getCustomerid(),toAccId,amount);
}
private void meterDebitEvent( String bankId,String userId,String fromAcc,
BigDecimal amount) {
try {
ICEIEventEmitter emitter = CEIEventManagementFactory.createEventEmitter();
emitter.emitEvent("Jivaro", "Jivaro", "transfer_funds", new String[] {
"OpCode", "AgentID", "BfsID", "SubscriberID", "UserID",
"HostName", STATIC_Metering_ACTID, STATIC_Metering_AMOUNT},
new String[] { STATIC_Metering_DEBIT_OPCODE,
STATIC_Metering_AGENTID, STATIC_Metering_BFSID, bankId, userId,
java.net.InetAddress.getLocalHost().getHostName().toString(),
fromAcc, amount.toString()});
} catch(Exception e) { e.printStackTrace(); }
}
private void meterCreditEvent(String bankId,String userId,String toAcc,
BigDecimal amount) {
}
// some code is ignored here
} |
Emitting an event from an SCA component
The CEIEventEmitterRouter (in the downloadable artifacts) wraps the CEIEventEmitter as a Web service. You can then import the Web service into WebSphere Integration Developer and wire an invoking SCA component to it (see Figure 3), which enables the CEIEventEmitter to be invoked as a service. If performance is an issue, you can include the artifacts in the SCA module and call it as a standard Java bean.
Figure 3. CEIEventEmitter as a service

The CEIQueryService (see Figure 6) enables you to query the CEI persistent state and return data from CBEs within a specified correlation sphere. The correlation sphere groups all related CBEs together.
When the CEIEventEmitter persists events, a trackingId forms a correlation sphere, which is used to correlate related events. You can retrieve all the related CBE events. The interface to this artifact is a Web service, and the events are returned in a Plain Old Java Object (POJO), instead of a CBE, for easy access.
This artifact has two parts. The first part is the actual Web service and its related artifacts, which are contained in EAR file CEIQueryServiceEAR. These artifacts are deployed on the WebSphere Process Server instance. The second part of the CEIQueryService artifact is the client interface to the Web service and its related proxy classes. This is contained in EAR file CEIQueryServiceClientEAR. The client interface is an EAR file for easy access to the WAR for testing. The client project provides the WebService proxy and the needed classes to invoke the operations on the CEIQueryService. Typically, you start the Web service by instantiating the CEIQueryServiceProxy and then invoking the desired operation on the Web service. The data returns in a CEIQueryEvent object that contains an array of CEIQueryEventData objects.
Figure 4. CEIQueryService class diagram

There are some samples of how to invoke the CEIQueryWebService located in CEIQueryServiceClientWeb\WebContent\sampleCEIQueryServiceProxy. The sample enables you to test the Web service using the generated proxy. Select TestClient.jsp, and then Run > Run on Server. A Web browser opens, and you can select an operation to run. Remember to change the endpoint if the service is deployed on a remote host.
Note: In order to compile all projects successfully, make sure the WPS_RUNTIME/CEI/client/events-client.jar file is in the project build path. WPS_RUNTIME is the directory where WebSphere Process Server is installed, such as C:/Program Files/IBM/Rational/SDP/6.0/runtimes/bi_v6.
Using the CEIMeteringViewPortlet
The CEIMeteringViewPortlet (see Figure 5) is a portlet that enables you to view metering events that were created with the CEIEventEmitter. The CEIMeteringPortlet retrieves events using the CEIQueryService and then lists them in a portlet page (see Figure 6). The portlet enables the user to filter events based on date, agent, or subscriber.
Table 3. Fields description
| Criteria name | Usage |
|---|---|
| Start date | No events generated before this date are shown. |
| End date | No events generated after this date are shown. |
| Agent | Events this agent generates are shown. The agent is a string that identifies the event source. It is an arbitrary string that the application selects to send the event. It corresponds to the sourceComponentId/@application attribute of a CBE. |
| Subscriber | Events this subscriber subscribes to are shown. Subscriber is a string that the event source selects. It identifies parties interested in this event. It corresponds to an ExtendedDataElement of a CBE with the name SubscriberID. |
The filtering criteria fields are optional. The portlet uses only the available criteria to filter events. This feature is especially useful for many events.
One of the features of this portlet is the capability to use an XPATH query string to filter. The CEIMeteringPortlet constructs an XPATH query string from the user-specified criteria and sends this query string to the CEIQueryService. The CEIQueryService then takes the XPATH query string and retrieves the events, filtering out the non-compliant events.
Figure 5. Class diagram of the CEIMeteringViewPortlet

Figure 6. CEIMeteringViewPortlet summary view

You can select an event to see its attributes in detail (see Figure 7).
Figure 7. CEIMeteringPortlet detail view

This article describes why making your composite application measurable is important. It describes the role of business-level events and presents three artifacts you can use to generate, query, and view business-level events in the context of a composite application. With the help of these reusable artifacts, your composite application can be measurable, thus laying the groundwork for improving the entire business process.
| Description | Name | Size | Download method |
|---|---|---|---|
| Assets projects in server side for this article1 | assetsserviceside.zip | 117KB | HTTP |
| Assets projects in client side for this article | assetsportlet.zip | 2,905KB | HTTP |
| List of all projects in above downloadable files | projectlist.zip | 6KB | HTTP |
Information about download methods
Note
- The artifacts are provided in Project Interchange Format. In order to import the artifacts simply select File>Import and then Project Interchange.
Learn
- Use an RSS feed to request notification for the upcoming articles in this series. (Find out more about RSS feeds of developerWorks content.)
-
Get the specification and related material for Business Process Execution Language for Web Services.
-
Refer to the Common Base Event specification.
-
Learn more from Best Practices for the Common Base Event and Common Event Infrastructure.
-
See Event Management Best Practice for more about event management.
-
Refer to Common Base Event best practices: Getting it right the first time.
-
Learn more from Common Base Event best practices: Properties and elements at a glance.
-
Stay current with developerWorks technical events and webcasts.
- The IBM SOA Web site offers an overview of SOA and how IBM can help you to get there.
-
Visit the SOA and Web services zone on developerWorks to learn more about SOA.
Discuss
-
Participate in developerWorks blogs and get involved in the developerWorks community.
-
Collaborate with a community of architects and developers in the SOA and Web services discussion forums.

Javier Garcia is an advisory software engineer with over 20 years of development experience. He is currently working in the SWG Strategy and Technology department with a focus on SOA and composite applications.






