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]

Building SOA composite business services, Part 4: Develop measurable composite applications with the Common Event Infrastructure

Javier Garcia (javierg@us.ibm.com), Advisory Software Engineer, IBM, Software Group
Photo of Javier Garcia
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.
Duo Wei (David) Sun (sunduow@cn.ibm.com), Staff Software Engineer, IBM
Photo of DuoWei (David) Sun
DuoWei (David) Sun is a staff software engineer in China Software Development Lab (CSDL). He is currently working in the SOA development area.
Zhi Gan (ganzhi@cn.ibm.com), Staff Software Engineer, IBM
Photo of Zhi (James) Gan
Zhi Gan is a software engineer at the IBM China Development Lab. He joined IBM after receiving a Ph.D. in computer security from Shanghai JiaoTong University. He has extensive experience in SOA, AOP, and Eclipse. Now he focuses mainly on model-driven development with patterns.

Summary:  This article is the fourth in a series that considers the development of composite applications to enable business services. In order to determine if a composite application is meeting the stated business goals, the application needs to be measurable. This article examines how to develop measurable composite applications with the help of three reusable artifacts that are based on the Common Event Infrastructure. You can learn why the artifacts are needed and how to use them to measure a composite application.

View more content in this series

Date:  16 Feb 2007
Level:  Intermediate
Also available in:   Chinese  Korean  Russian

Activity:  4589 views
Comments:  

Introduction

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.


Generating CBE events

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
EditorMonitorable 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
ActivityDefault event name
InvokeCompletion forced, Entry, Exit, Expired, Failed, Retry forced, Skipped, Stopped, Terminated
ProcessCompensated, 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
ReceiveEntry, Exit, Terminated
ReplyExit, Failed, Skipped
ScopeCompensated, Compensating, Compensation failed, Entry, Event handler escalated, Event received, Exit, Failed, Failing, Skipped, Terminated
StaffAssigned, 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


Viewing CBEs

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
CBE Event Browser

Using reusable CEI artifacts

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.

Using the CEIEventEmitter

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
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
CEIEventEmitter as a service

Using the CEIQueryService

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
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 nameUsage
Start dateNo events generated before this date are shown.
End dateNo events generated after this date are shown.
AgentEvents 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.
SubscriberEvents 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
Class diagram of the CEIMeteringViewPortlet

Figure 6. CEIMeteringViewPortlet summary view
CEIMeteringViewPortlet summary view

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


Figure 7. CEIMeteringPortlet detail view
CEIMeteringViewPortlet summary view

Conclusion

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.













Downloads

DescriptionNameSizeDownload method
Assets projects in server side for this article1assetsserviceside.zip117KB HTTP
Assets projects in client side for this articleassetsportlet.zip2,905KB HTTP
List of all projects in above downloadable filesprojectlist.zip6KBHTTP

Information about download methods

Note

  1. The artifacts are provided in Project Interchange Format. In order to import the artifacts simply select File>Import and then Project Interchange.

Resources

Learn

Discuss

About the authors

Photo of Javier Garcia

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.

Photo of DuoWei (David) Sun

DuoWei (David) Sun is a staff software engineer in China Software Development Lab (CSDL). He is currently working in the SOA development area.

Photo of Zhi (James) Gan

Zhi Gan is a software engineer at the IBM China Development Lab. He joined IBM after receiving a Ph.D. in computer security from Shanghai JiaoTong University. He has extensive experience in SOA, AOP, and Eclipse. Now he focuses mainly on model-driven development with patterns.

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=196457
ArticleTitle=Building SOA composite business services, Part 4: Develop measurable composite applications with the Common Event Infrastructure
publish-date=02162007
author1-email=javierg@us.ibm.com
author1-email-cc=flanders@us.ibm.com
author2-email=sunduow@cn.ibm.com
author2-email-cc=flanders@us.ibm.com
author3-email=ganzhi@cn.ibm.com
author3-email-cc=flanders@us.ibm.com

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).

Try IBM PureSystems. No charge.

Special offers