Part 1 of this series introduced you to the trade system scenario that is used throughout this series. In Part 2, you built and tested the trade system application. This article uses the project for the trade system scenario introduced in Part 2, which guides you through the process of defining and deploying the Trade system scenario artifacts. In order to understand this article, you should have read and completed the steps in Parts 1 and 2.
In this article, you'll learn how to generate an Action event that is pushed from WebSphere Business Events (hereafter called Business Events) to a Common Event Infrastructure (CEI) server, which distributes events to WebSphere Business Monitor (Monitor). You'll also learn how to export the event schema from Business Events so that it can be used in authoring a monitor model that is deployed on the Monitor server to analyze the event data and display the it on the Monitor dashboard.
Overview of WebSphere Business Monitor
WebSphere Business Monitor is business-activity monitoring (BAM) software that is capable of monitoring business applications running almost anywhere, as long as they can generate Common Base Events (CBEs) from their activity. These applications must be able to generate a series of events, which encapsulate the business data, and forward them to the common event infrastructure (CEI). CEI is IBM's implementation of a consistent approach for the creation, transmission, persistence and distribution of a wide range of business, system and network events, based on common base events. Monitor uses CEI to receive events from applications. The content and format of the events forwarded to Monitor determine how easy it is for customers to author monitor models and monitor meaningful business data.
To monitor events from Business Events, you must create a monitor model using the WebSphere Business Monitor Development Toolkit. A monitor model is an XML document that describes how to gather business data from incoming events, group them around the same entity and provide a context. It also describes metrics and key performance indicators (KPIs), their dependencies on incoming events, conditions warranting business actions, and outbound events that report such conditions and might trigger business actions.
The model can also structure the data and persist it for dimensional analysis, or to identify trends. You can visualize data using annotated diagrams.
Once the monitor model is created and deployed on the Monitor server, it begins processing events from sources such as WebSphere Business Events, according to the definitions in the monitor model logic. For more information about event sources that forward events to Monitor, refer to Business Activity Monitoring with WebSphere Business Monitor V6.1. Chapter 1 provides an overview of CEI, an embeddable technology that provides basic event management services for WebSphere Business Monitor.
Install and configure Business Events and Monitor
The sample that accompanies this article was developed and tested using a Windows 2003 system on which Business Events V6.1 was installed. Business Events V6.1 also installed WebSphere Application Server (Application Server) V220.127.116.11. The CEI server was enabled on Application Server. Refer to the Application Server V6.1.1 Information Center for instructions on enabling CEI.
Monitor was installed on a different Windows XP system, and the Monitor server was configured to receive CEI events from the remote CEI server enabled with the Business Events installation. In order to do this, you need to install the cross-cell files, create the remote service integration bus, and create the link between the local and remote buses. The cross-cell files are required to support a remote CEI server on Application Server V6.1. The events generated by Business Events were distributed to the remote CEI server and processed by the Monitor model.
In order to set up a cross-cell configuration to a remote CEI system, follow the instructions in the Remote CEI on WebSphere Application Server 6.1 topic in the Monitor Information Center.
You can also install Business Events and Monitor on a single system and have then running in the same Java™ Virtual Machine (JVM). Doing this eliminates the need for the remote CEI configuration. To install Business Events V6.1 and Monitor V6.1.2 on the same server follow these steps:
- Install Business Events V6.1 with Application Server V18.104.22.168 and DB2® 9.5.
- Upgrade Application Server V22.214.171.124 to Application Server V126.96.36.199, if you are using Application Server V6.1.2.
- Install the Monitor V6.1.2 production version.
- Use the Profile Management Tool to augment the profile created during Business Events installation with the Business Monitor template.
- Make sure to install the Monitor Toolkit that is at the same level as the Monitor server in order to use the monitor model provided with this article.
Note: The CEI server is enabled during Business Monitor installation and does not have to be enabled separately.
For more information installation, see the Installation and Operation Guide in the Business Events V6.1 Information Center and the Installing WebSphere Business Monitor topic in the Monitor V6.1 Information Center.
Send Business Events actions to Monitor
The integration scenario
As described in previous parts in this series, the scenario is based on a trading system in which a Business Events application processes buy and sell events. In the trade system scenario, Business Events receives Sell and Buy events that have attributes describing the customer, stock, the date and time when the trade took place, the number of shares, and the price. Policies are defined to detect patterns in these events. When a Sell occurs after a Buy event within an hour for the same stock and the same customer, a SellAfterBuy action is generated. This action is pushed out to a touchpoint--in this case Monitor. If one customer completes three sells after buys within a day, for the same or different stocks, a SpeculativeCustomer action is generated and pushed out to the touchpoint, Monitor. These actions are outbound events from Business Events to Monitor. The embedded message queue connector provides the connection from Business Events to the CEI server that distributes events to Monitor, and it sends a correctly configured Action packet to the specified CEI JMS queue. Figure 1 illustrates the connection from Business Events to Monitor using the message queue connector.
Figure 1. Embedded Message Queue Connector
Monitor captures business-related data in the incoming Common Base events such as stock ID, quantity and price, and transforms the variables into metric and KPI values. It can display the KPI that measures the number of SellAfterBuys that occur in a week and send alerts if such activities exceed a set threshold. The SellAfterBuy KPI can be set up for different regions of a country, can be displayed on a dashboard in different formats for these different regions, and can send alerts when a threshold is exceeded to warn of suspicious trading patterns.
A sample project for a Trade System application is provided with this article, in which the touchpoints, events, actions, intermediate objects, and message queue connectors are already defined. In You'll learn how this project was defined to send action events to Monitor.
Import the sample project
- Open the Design Data tool.
- Select File => Open Project, as shown in Figure 2.
Figure 2. Import sample project
- Click Browse, select the sample project and click Open.
Design Data now contains the sample Trade System project.
Define the actions
Once you've imported the tradesystem.xml project file, you'll see that the Touchpoint pane is populated with a number of entries. The Business Events actions that will be forwarded to Monitor are defined in this Touchpoints pane.
To see how these actions are defined, do the following:
- Right-click Sell After Buy and select Action Properties.
Figure 3. Modify action properties
- Select the Connection tab and clickMessage Queue Connection
, as shown in Figure 4.
Figure 4. Message Queue Connection
- Click Configure.
- The Common Event Infrastructure (CEI) supports the direct placement of
a properly formatted CBE XML on its input queue without using their
emission APIs. This allows any Application Server-based application
like Business Events to easily route events to the CEI queues. In
order for this action to generate CBE XMLs that will be forwarded to
CEI, you need to specify the following in the Message Queue Action
Connection dialog, as shown in Figure 5:
- Format: CBE (WBM)
- Queue Type: JMS Queue
- Queue Name: jms/cei/EventQueue
- Message Type: CREATE_EVENTS_NOTIFICATION_V2_0
Figure 5. Message Queue Action Configuration
- In the Provider dialog, enter the following information, as shown in
- Context Factory Class: com.ibm.websphere.naming.WsnInitialContextFactory
- URL: iiop://<server>:<port>. To get the port value, open the Application Server administrative console and find the CEI server Application Server bootstrap port address. For the sample, the URL is iiop://localhost:2809.
- Factory Name: jms/cei/EventQueueConnectionFactory
- Username: Enter a valid user name if JMS requires a user ID and password.
- Password: Enter a password associated with the user name if JMS requires a user ID and password
Figure 6. Provider Configuration
- Repeat these same steps for the Speculative Customer action.
Export the schema for the actions
When the actions are forwarded to the CEI server, Monitor can process them. However, you must first create and deploy a monitor model on the Monitor server. To create the monitor model, you first need to export the schemas of the Sell After Buy and Speculative Customer actions from Business Events.
Note: A sample monitor model with exported schema is provided for download with this article. You can use the following steps to export other schemas for inclusion in your monitor model. In this article, we won't walk through all the steps of authoring a monitor model. Refer to the Monitor Information Center for more information on this topic.
To export the schema, complete the following steps:
- Open the sample Trade System project.
- In the Touchpoint pane, right-click Sell After Buy and select Action Properties.
- Select the Action tab, as shown in Figure 7, and click
Export packets and schemas, then select CBE Payload
Figure 7. Export SellAfterBuy schema
- Enter the host portion of the target namespace for this schema, as
shown in Figure 8, then click OK. This value must match the
value of the Business Events system name. Otherwise, it will result in
a mismatch between the generated target namespace in the schema and
the namespace specified in the generated CBE XML.
Figure 8. Specify the target nameSpace
- Save the SellAfterBuy.xsd file.
- Also export the CBE Example for later reference. Repeat Steps 3 and 4, selecting CBE Example in Step 3. Listing 1 shows the sample. Notice the target namespace in bold.
Listing 1. CBE example for Sell After Buy action
<wbe:event-bundle xmlns:wbe="http://www.ibm.com/xmlns/prod/websphere/businessEvents/6.1.0"> <wbe:connector-info> <wbe:name>Sell After Buy</wbe:name> <wbe:version>2.2</wbe:version> <wbe:system>LATHAZ</wbe:system> <wbe:timestamp>2008-06-18T03:38:13Z</wbe:timestamp> <wbe:log-info> Test values from WebSphere Business Events:Design Data </wbe:log-info> </wbe:connector-info> <wbe:event-info> <wbe:name>Sell After Buy</wbe:name> <wbe:type>action</wbe:type> <wbe:workflow/> </wbe:event-info> <wbe:payload-data> <wbe:payload name="Trade Out"> <payload:Trade-Out-array xmlns:payload= "http://LATHAZ/wbe/action/Sell-After-Buy"> <payload:Trade-Out> <payload:CustomerID>String_CustomerID</payload:CustomerID> <payload:StockID>String_StockID</payload:StockID> <payload:Date>2008-06-18T03:38:13Z</payload:Date> <payload:Quantity>9.9</payload:Quantity> <payload:Price>9.9</payload:Price> <payload:Key>String_Key</payload:Key> </payload:Trade-Out> </payload:Trade-Out-array> </wbe:payload> </wbe:payload-data> </wbe:event-bundle> </CommonBaseEvent>
Import the monitor model into the Monitor Toolkit
A project interchange file, TradeSystemPI.zip, with a simple monitor model is provided for download with this article. Once you've Installed the Monitor Toolkit, which must be at the same level as the Monitor server, import the project file into the Monitor Model editor. For more information, refer to Importing shared projects in the Monitor Information Center.
- Start WebSphere Integration Developer or Rational Application Developer and specify a new workspace, for example: c:\TradeSystem.
- Open the Business Monitoring perspective.
- To import the provided project interchange file, TradeSystemPI.zip,
select File=> Import => Other =>Project
Interchange File. Browse to the TradeSystemPI.zip file, and
click Finish, as shown in Figure 9.
Figure 9. Import the project interchange file
- Expand the TradeSystem project in the Project Explorer pane to view the parts of the monitoring model.
Open the TradeSysten project and examine the imported schema events. There are two schemas that are specific to Business Events:
- WBEEvent.xsd describes the static content of a Business Events action that is the same for every action. This xsd file is static and is not exported from Business Events.
- SellAfterBuy.xsd: describes the SellAfterBuy action in a format that can be consumed by Monitor. This is dynamic content that varies and is often called the business payload.
Together, the two schema definitions define the Business Events action that flows in the xs:any slot of the Common Base Event.
Note: The SellAfterBuy.xsd was exported from Business Events and the host portion of the target namespace specified in this schema file may not match your Business Events system name. You need to modify the SellAfterBuy schema file, shown in Listing 2, in the monitor model to match your Business Events system name, as described in the following steps.
- Open the SellAfterBuy.xsd in the Monitor Model editor. Replace all occurrences of host name LATHAZ with your Business Events system host name.
- In the SellAfterBuy.xsd, replace all occurrences of LATHAZ with your Business Events host name. Refer to Step 8 in Export the schema for the actions to determine the targetNamespace value.
Listing 2. SellAfterBuy schema file
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://LATHAZ/wbe/action/Sell-After-Buy" xmlns:tns="http://LATHAZ/wbe/action/Sell-After-Buy"> <element name="Trade-Out-array"> <complexType> <sequence> <element maxOccurs="unbounded" minOccurs="0" name="Trade-Out">
A Sales_MC monitoring context defines all of the related data that will be collected from the SellAfterBuy inbound event about a stock sale.
The inbound event defined in the monitoring context is SellAfterBuy. Two event parts are defined. One part, called EventInfo, describes the type of the static event information and another part, called TradeOutArray, describes the type of the dynamic business payload.
The business data flowing through the system determines the dynamic content in an event. This information is typed by user-defined XSDs available in WebSphere Integration Developer. Only certain events can contain this information, which is often called the business payload. When you're generating a monitor model from an application, these events are shown with a flag and package icon in the Monitor Model editor, while events that can never carry business information are shown with a flag icon.
When an inbound event is based on an event that carries a business payload, an event part that describes the type of the business payload is created in the inbound event in the monitor model. Listing 3 shows a snippet from the monitor model that defines the inbound event parts, filter condition and correlation expression.
Listing 3. Monitor model definitions example
Filter Condition: /* This expression accesses the name in the event-info within the CBE*/ SellAfterBuy/My_Event_Part/wbe:name = 'Sell After Buy'. Correlation Expression: /* This expression accesses then Key in the Trade-Out element within the CBE */ StockIDKey = TradeEvent/My_Event_Part2/tns:Trade-Out/tns:Key <inboundEvent displayName="TradeEvent" id="TradeEvent" multipleCorrelationMatches="raiseException" noCorrelationMatches="createNewContext" oneCorrelationMatch="deliverEvent" rootElement="cbe:CommonBaseEvent"> <description></description> <eventPart displayName="My Event Part" id="My_Event_Part" path="cbe:CommonBaseEvent/wbe:event-bundle/ wbe:event-info" type="wbe:EventInfo"> </eventPart> <eventPart displayName="My Event Part2" id="My_Event_Part2" path="cbe:CommonBaseEvent/ wbe:event-bundle/wbe:payload-data/ wbe:payload[@name='Trade Out']/tns:Trade-Out-array" type="tns:Trade-Out-array"> </eventPart> <correlationPredicate expression="StockIDKey = TradeEvent/My_Event_Part2/tns:Trade-Out/tns:Key"/> <filter expression="TradeEvent/My_Event_Part/ wbe:name = 'Sell After Buy' "/> </inboundEvent>
Refer to the InstalliMonitor Information Center for more information about importing the project file into the Monitor Model editor, and creating and deploying monitor models on the Monitor server. The provided model has a single monitoring context that subscribes to the SellAfterBuy event. It also defines one KPI that tracks the number of SellafterBuyEvents for the last 7 days. You can enhance the provided model, as desired.
Generate the monitor model EAR file
Complete the following steps to generate the monitor model EAR file from the provided project interchange file.
Note: You can use the EAR file provided for download with this article instead of generating your own.
- Right-click TradeSystem.mm in the Project Explorer, and select
Generate Monitor J2EE Projects, as shown in Figure 10.
Figure 10. Generate Monitor J2EE projects
- Click Finish in the Generate Monitor J2EE Projects dialog,
shown in Figure 11, and wait for generation to complete.
Figure 11. Generate EAR file
- To export the monitor EAR file, right-click TradeSystem.mm in the Project Explorer and select Export => J2EE => EAR, and click Next.
- Select the EAR application and the destination for the EAR file as
shown in Figure 12, and click Finish.
Figure 12. Specify information about EAR file
Now you're ready to deploy the EAR file on the Monitor server.
Deploy the monitor model on the Monitor Server
Before deploying the EAR file, make sure the Monitor server is running, then start the administrative console for the Monitor server.
- From the Application Server administrative console, select Applications => Monitor Models. The table that is displayed lists all of the currently installed monitor models.
- Click Install.
- Specify the location of the EAR file you want to install, as shown in
Figure 13. Deploy the EAR file on the server
- Select Show me all installation options and parameters, and click Next.
- On the Preparing for the Application Installation page, click
If an application security warning displays, click Continue. This warning is for informational purposes.
- The Install New Application page is displayed.
Note: If you have configured a remote CEI server, you must modify the CEI options to specify the remote host name, RMI port and security settings. See the Select Monitor model CEI options in the Monitor Information Center.
- When you've finished any CEI modification needed, click
Summary, and verify that all information is correct, as
shown in Figure 14.
Figure 14. Verify deployment information
- To review the model installation information, click Review changes before saving or discarding, or to save the model, click Save directly to the master configuration.
- Select Applications => Monitor Models. Check to make sure that the TradeSystem model status is started--it should be green. If not, wait a few seconds or refresh the status by clicking on the refresh icon on the Status column.
For more information about deploying your monitor model on the Monitor server, refer to Installing a monitor model using modified settings in the Monitor Information Center.
Once you've completed all the steps to deploy the model and saved it to the Application server master configuration, you need to verify that the model has installed successfully. To do this, in the Application Server administrative console, click Applications => Monitor Models and make sure the model application is running.
Displaying the Instances and KPI views on the dashboard
To open the dashboard, point your Web browser to http://localhost:9080/BusinessSpace. The port number may be different on your system.
Use the BusinessSpace dashboard to import the dashboard, TradeSystem.data, provided with this article, so that you can see the KPI and Instances view.
To import a dashboard, complete the following steps:
- Go to the BusinessSpace Space Browser, as shown in Figure 15, and
click Import Space.
Figure 15. Import the dashboard
- Browse to the directory that contains the file you want to import, as
shown in Figure 16, 4. and select the data file, TradeSystem.data,
that contains the dashboard that you want to import.
Figure 16. Import Tradespace.data
- Click OK. A new dashboard is created. The importer of the dashboard, in this case you, owns the imported dashboard.
You can now see the Instances view and the KPI Gauge.
The sample model does not explore all the available monitoring capabilities, but you can extend the model with more monitoring contexts, alerts, and reports.
You must now generate some events to see data in the dashboard.
Deploy your configuration and prepare for testing
To deploy your configuration in preparation for testing, complete the following steps:
- To deploy your Business Events changes, select Tools =>
Repositories in the Design Data tool, as shown in Figure 17.
Figure 17. Open repository
- In the Repository window, select an element from the list of artifacts in the Project pane, then press Ctrl+A to select them all, and click Add in. All elements, including your changes, are added to the repository.
- Stop the Business Events runtime so that it can retrieve the latest configuration information from the repository.
- Open an Application Server administration console and log in.
- Select Enterprise Applications from the left column. You'll see
the current state of the Business Events runtime, as shown in Figure
18. The green application status indicates that the application is
Figure 18. Business Events runtime
- Check WBERuntimeEar and click Stop.
- After the runtime stops and the status turns red, check WBERuntimeEar again and click Start. The runtime should soon show a green application status indicating that is has started.
Now we're ready to test the sample project.
Test your configuration
In order to forward actions to Monitor, you need to export the sample event packets to the c:\wbetmp\testdata directory. You may also use the provided sample aEvent_Buy.xml and bEvent_Sell.xml if you want to skip the steps to export the sample event packets.
- Right-click the Buy event in the Touchpoints pane and select
Event Properties, as shown in Figure 19.
Figure 19. Select Buy event properties
- In the Event Buy Properties dialog, select the Event tab.
- Click Export packets and schemas, then select WBE Events
Packet Example, as shown in Figure 20.
Figure 20. Export Buy event sample
- Save the file aEvent_Buy.xml to the c:\wbetmp\testdata directory and
- Repeat these steps to save the sample Sell event, which is located
below the Buy event in the DirectorData. Save the Sell sample to the
c:\wbetmp\testdata directory and rename it
- When executing the sample project, make sure that all generated Buy
events are saved with a prefix of "a" (for example, aEvent_Buy.xml)
and all Sell events have a prefix of "b" (for example,
bEvent_Sell.xml). The sample project has been configured to
distinguish between the incoming Buy and Sell events based upon the
prefix of the file. This allows the user to stagger the order in which
events are processed and ensure that certain events are consumed
When a Buy event is followed by a Sell event within an hour for the same stock and the same customer, a SellAfterBuy action is generated. Therefore, we need to generate the Buy event first, followed by the Sell event.
- Save the Buy event file, and open it with an xml editor to examine the structure of the event payload. Listing 4 shows the Buy event XML file.
- Ensure that there are no nulls embedded at the end of the file.
Listing 4. Buy event XML file
<connector name="Trade System" version="2.2"> <connector-bundle name="Buy" type="event"> <connector-object name="Trade"> <field name="CustomerID" type="String">String_CustomerID</field> <field name="StockID" type="String">String_StockID</field> <field name="Date" type="DateTime">2008-05-24T14:07:10Z</field> <field name="Quantity" type="Real">9.9</field> <field name="Price" type="Real">9.9</field> </connector-object> </connector-bundle> <system>LATHAZ</system> <timestamp>2008-05-24T14:07:10Z</timestamp> <loginfo>Test values from WebSphere Business Events:Design Data</loginfo> </connector>
- Edit all the event files and change the date fields in the events to the current date. Otherwise the monitor model will not calculate the values for the last 7 days.
- To start the connectors, go to the \director\bin directory, for
example: C:\<wbe install>\director\bin, and run
This initiate the connectors, and opens a command window displaying the start-up and the scan for the event files you've created and saved to the Business Events event directory. You'll be able to see your events being processed by the connector in the command line window.
- Copy aEvent_Buy.xml from c:\wbetmp\testdata to c:\wbetmp. Wait a minute for the event to be consumed. You can watch for it in the connectors command window.
- Copy bEvent_Sell.xml from c:\wbetmp\testdata to c:\wbetmp. Wait a minute for the event to be consumed. You can watch for it in the connectors command window.
- The Buy and Sell events generate the SellAfterBuy Action event, as
shown in Figure 21.
Figure 21. Connectors
- Do the following to ensure that there are no problems with the
- Check to ensure that the events you have created and saved in the the c:\wbetemp\ event directory have been deleted.
- Check the Application Server logs.
- Check the Connector log, which is located at C:\<WBE INSTALL>\director\logs filename WBERuntime.connectors.log.
View the data in the Monitor dashboard and database
Open the BusinessSpace dashboard. You should be able to see one instance in the Instance view.
You should also be able to see data in the KPI views, when you hover over the KPIs. The gauge indicator should indicate one instance of SellAfterBuy, as shown in Figure 22.
Figure 22. Monitor dashboard with KPIs
You should also be able to see the data in the database. Use a tool, such as DB2 Control Center, to view the data. Look at the data in the monitor database, whose default name is MONITOR. Open the table MCT_SALES_MC_20080809010432. This table should contain one record that reflects the SellAfterBuyAction event that was received by Monitor, as shown in Figure 23.
Figure 23. Data in the Monitor database
In this article, you walked through the following steps required to forward events from WebSphere Business Events to WebSphere Business Monitor.
- Using the WebSphere Business Events Design Data tool, you:
- Created an application with actions.
- Configured these actions so that they will forward to Monitor (the touchpoint).
- Exported the schemas for the defined actions to the file system/
- Imported the action schemas into the Monitor Model Toolkit editor to author monitor models.
- Deployed the monitor models using the WebSphere Application Server administrative console.
- Started the Business Events connectors process to start forwarding generated actions to Monitor.
- Viewed the action events received and processed by Monitor in the dashboard.
The integration of Business Events and Monitor allows you to take advantage business data analysis and reporting capabilities available with Monitor, and to use the KPIs and notification services provided by the Monitor Action Manager component.
|Event packet and dashboard||EventsAndDashboard.zip||2KB|
|Business Events schemas||EventsSchemas.zip||2KB|
|Monitor model EAR file||TradesystemMonitoringModel.zip||199KB|
|Project file for trade system app||tradingsystem.zip||3KB|
|Monitor model project interchange||TradeSystemPI.zip||4KB|
- Remote CEI on WebSphere Application Server 6.1: The topic in the WebSphere Application Server Information Center describes how to enable the WebSphere Business Monitor server to receive CEI events from a remote CEI server.
- Business Activity Monitoring with WebSphere Business Monitor V6.1: Chapter 1of this IBM Redbook provides an overview of CEI.
- WebSphere Business Monitor Information Center: Get complete product documentation.
- WebSphere Business Events: Get product information, including features, benefits, demos and trial downloads.
- WebSphere Business Events V6.1 Information Center: Get complete product documentation.
- developerWorks BPM zone: Get the latest technical resources on IBM BPM solutions, including downloads, demos, articles, tutorials, events, webcasts, and more.
- Business Process Management enabled by SOA: Get product information, including features and benefits.
Dig deeper into Business process management on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Experiment with new directions in software development.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.