Business Event Processing with WebSphere Business Events, Part 2: Building a business events application

Part 1 of this series introduced you to key WebSphere® Business Events concepts and tools. In Part 2, you'll learn how to build and test a simple Business Events application, which you'll use to integrate with other IBM products in future articles in the series.

Share:

Doina Klinger, Advisory Software Engineer, IBM

Doina Klinger photoDoina Klinger is an Advisory Software Engineer at the IBM Hursley Software Laboratory. She is a developer for WebSphere Business Events. She has worked previously as a developer and development lead on a number of WebSphere products and components, most recently, WebSphere Enterprise Service Bus and WebSphere Integration Developer. She has an interest in Eclipse and messaging and event processing technologies. Doina joined IBM in 2000, having received an MSc in Computer Science from Purdue University. You can reach Doina at dklinger@uk.ibm.com.



Xiaoming Zhang (zhang@uk.ibm.com), Software Engineer, IBM

Xiaoming Zhang photoXiaoming Zhang is a Software Engineer at the IBM Hursley Software Lab. He has done testing, development, and Level 3 service for WebSphere MQ, WebSphere Message Broker, and WebSphere Business Events. Before joining IBM in 1998, Xiaoming was a lecturer in Computer Science at Brunel University in the UK. Xiaoming graduated from Fudan University in China, and received a Ph.D from the University of Wales Swansea, UK. You can reach Xiaoming at zhang@uk.ibm.com.



Mark Hiscock (mark.hiscock@us.ibm.com), Software Engineer, IBM

Mark Hiscock photoMark Hiscock works at the IBM Hursley Software Lab, where he has worked in test, Level 3 support, scenarios testing and lab services for WebSphere MQ and WebSphere Message Broker. He now works as a developer for WebSphere Business Events. In his spare time Mark enjoys Kung Fu, cycling and shiny gadgets! You can reach Mark at mark.hiscock@uk.ibm.com.



01 October 2008

Also available in Chinese Japanese Spanish

Overview of the scenario

In this series, we'll use a sample scenario to show how Business Events works. The scenario requires identifying and appropriately responding to patterns of events over time. We'll use simplified version of a regulation compliance use case from the financial industry, in which we need to detect speculative action in a trade system. For more information on the scenario, see Part 1.

To demonstrate the integration of Business Events with other IBM products, which we'll cover in future articles in this series, the sample implementation generates three types of actions. The scenario only requires the SpeculativeCustomer action to be reported. However, we'll generate the intermediate actions, too, for the purpose of illustration and to help with the integration.

Notes:

  • Part 2 of this series assumes that you've read Part 1, and are familiar with the core concepts of Business Events described in that article.
  • The steps in this article were executed in a Windows® environment.

Overview of the process

To build the application to implement the scenario, you'll use the WebSphere Business Events Design Data tool to complete the steps below. These steps would normally be done by an IT specialist.

  1. Define the business systems, called touchpoints, that are to be integrated. A touchpoint is a group of related event and action definitions.
  2. In the touchpoints, define the activities that initiate a cross-system process (events) and the activities (actions) that are performed when the event patterns are identified. For example, three Sell events by a customer after Buy events within a day for the same customer and stock, result in a SpeculativeCustomer action.
  3. Create a business object layer, called intermediate objects, which serves as a placeholder for data used in event evaluation. All data going into and out of the run-time system goes through intermediate objects. For example, a Customer intermediate object may contain fields (Name, Address, State, and so on) whose values are obtained from event and may also contain contact information (Last Order Date, Email Address) whose values are obtained from a database table.

Next, you'll use the Business Events Design tool to retrieve the definitions created in the previous steps and use them to define the business logic. A business analyst typically completes these steps.

  1. Define interaction sets (a collection of interaction blocks containing business logic) used at run-time by the Business Events run-time server to detect, correlate, and respond to simple and complex event patterns.
  2. Define filters used to specify under what conditions an interaction block is true.

Note: Definitions for all Business Events components are stored in the same repository, providing a completely integrated environment. When the Business Events run-time server starts, it retrieves the most current set of definitions from the repository and compiles the interaction sets, which evaluate incoming events and generate associated actions.


Build the application

This section describes the steps you need to complete to build the Business Events application using Design Data tool. You'll describe the events and the resulting actions, as well as define the intermediate objects.

You'll complete the following steps:

  1. Define a touchpoint.
  2. Define events and one event object.
  3. Create actions and one action object.
  4. Create an event that is generated as a result of an action.
  5. Define one intermediate object.
  6. Define the mapping between intermediate object fields and event fields.
  7. Define the mapping between action fields and intermediate objects.

Step 1: Define a touchpoint

To define a touchpoint, do the following:

  1. Start the Design Data tool by selecting Start => All Programs => IBM WebSphere Business Events 6.1 => Design Data.
  2. Expand the Touchpoints pane on the left . (You can collapse the others to save space.) Right-click in the left pane and select Insert Touchpoint.
  3. Specify the Trade System as the name.

Step 2: Define events

To define events, do the following:

  1. Right-click the new touchpoint and select Insert Event => Normal.
  2. Specify Buy as the name.
  3. Right-click the event and select Insert Event Object => Blank.
  4. Specify TradeObject as the name.
  5. Right-click the event object and select Insert Event Object Field. The Insert Field dialog opens. You'll use this dialog to insert fields into event objects, action objects and intermediate objects.
  6. Specify CustomerID as the name and select String as the data type, as shown in Figure 1.
    Figure 1. Insert a field in an event object
    Insert a field in an event object
  7. Repeat step 6 to add the following fields:
    • StockID with a type of String
    • Date with a type of DateTime
    • Quantity with a type of Real
    • Price with a type Real
  8. Create another new event, this time called Sell.
  9. Right-click Sell and select Insert Event Object => Shared, then select TradeObject.

The same event object is shared by the Buy and Sell events.

Step 3: Create the actions

To create the actions, complete the following steps:

  1. Right-click the Trade System touchpoint and select Insert Action => Normal.
  2. Specify Buy Ack as the name.
  3. Right-click the new action and select Insert Action Object => Blank.
  4. Specify TradeOut as the name.
  5. Right-click the TradeOut action object and select Insert Action Object Field.
  6. In the Insert Field dialog, shown in Figure 1, specify CustomerID as the name and select String as the data type. Repeat this for the following field names and types:
    • StockID with a type of String
    • Key with a type of String
    • Date with a type of DateTime
    • Quantity with a type of Real
    • Price with a type of Real

    Note: Business Events requires that every event defined must trigger an action via an interaction set. The Buy Ack action you just created meets this requirement for the Buy event. Later, you'll define an interaction set, which will illustrate the simplest policy of an event generating an action without a filter or a delay.

    In Figure 2, you see the Design Data tool, showing some details of the created action Buy Ack, including its action object TradeOut and the action object's member fields, such as CustomerID, on the right.

    Figure 2. Action and action object
    Act and action object
  7. Create a new action called SellAfterBuy by repeating the process above.
  8. Right-click the new SellAfterBuy action and select Insert Action Object => Shared, then select TradeOut.
  9. Repeat steps 1 and 8 to create the action Speculative Customer, which also uses the shared action object TradeOut.

Step 4: Create an event

Next, we'll create a synthetic event, which will enable Business Events to notice repeated occurrences of SellAfterBuy and send a SpeculativeCustomer action. To do this complete the following steps:

  1. Create a normal event called SellAfterBuySynEvent.
  2. Right-click the event and select Insert Action => To Fire This Event Synthetically. Accept the warning message that displays. The event is now renamed SellAfterBuySynEvent <- SellAfterBuySynEvent, and a new SellAfterBuySynEvent action is automatically created.
  3. Right-click SellAfterBuySynEvent and select Rename. Rename the event SellAfterBuySynAction. It is a good practice to avoid having the suffix Event in an action name. Renaming the action will cause the synthetic event to be renamed to SellAfterBuySynEvent <- SellAfterBuySynAction.

Step 5: Define an intermediate object

The next step is to define the intermediate object. The sample application uses a single intermediate object. To define the intermediate object, do the following:

  1. Expand the Intermediate Objects pane of the Design Data tool, then right-click in the pane and select Insert Intermediate Object => Blank.
  2. Specify TradeObject as the name.
  3. Right-click the new object and select Insert Intermediate Object Field. In the Insert Field dialog, specify CustomerID as the name and select String as the data type. Repeat this for the following field names and types:
    • StockID with a type of String
    • Date with a type of DateTime
    • Quantity with a type of Real
    • Price with a type of Real
    • Key with a type of String
  4. Drag and drop the intermediate object TradeObject from the Intermediate Objects section onto the SellAfterBuySynEvent <- SellAfterBuySynAction event.
  5. Drag and drop TradeObject from the Intermediate Objects section onto the SellAfterBuySynAction action. Figure 3 shows the details of the created synthetic event and synthetic action.
    Figure 3. A synthetic event
    A synthetic event

Step 6: Define mapping from event objects to intermediate objects

Next you need to specify how each of the event object fields is mapped to the intermediate object fields. This mapping is needed for all events, including the derived events. Most of the fields are filled in directly from the attributes of the Buy and Sell events. The Key field of the intermediate object is computed using a JavaScript™.

You can do the mapping using drag and drop actions from the source to the target. However, we'll describe here how to do the mapping with explicit selections:

  1. Expand the Buy event tree node, right-click on TradeObject and select Insert Field Constructor From Object => Trade Object => Customer ID, as shown in Figure 4.
    Figure 4. Add field constructors for the intermediate object
    Add field constructors for the intermediate object
  2. Repeat the previous step to insert field constructors for StockID, Date, Price and Quantity. Don't map the Key field. This specifies the fields of the intermediate object that are built from the event fields.

    Note: The tool shows you in square brackets the intermediate objects that are created for each event, as shown in Figure 5.

    Figure 5. Intermediate objects and the fields created from events
    Intermediate objects and fields created from events
  3. On the right side of the Touchpoints view, expand Buy => TradeObject => CustomerID and select Field in the Definition section of the editor.
  4. Click Insert object field and select CustomerID from the list of event fields, as shown in Figure 6.
    Figure 6. Set intermediate object field from event field
    Set intermediate object field from event field
  5. Repeat the last two steps to insert the corresponding fields in Date, Price, Quantity and StockID. This specifies all the fields of the intermediate object that are constructed from event fields.

    Note: In this example, the names of the fields are the same for the event object and the intermediate object, but they don't have to be.

    Because the Buy and Sell events share an event object, both Buy and Sell events result in the creation of a TradeObject intermediate object, as shown in Figure 7:

    Figure 7. Multiple events create the same intermediate object
    Multiple events create single intermediate object
  6. Define the Key field using a JavaScript expression as follows:
    1. Expand the Key field in the Intermediate Objects pane.
    2. In the Definition section, select JavaScript as the Type and enter the expression CustomerID +""+StockID, as shown in Figure 8:
      Figure 8. Define the Key field in JavaScript
      Define the Key field in JavaScript

      Note: The Design Data tool doesn't validate JavaScript expressions. Therefore, you need to make sure that the expression you enter is a valid JavaScript expression. A JavaScript test tool is available at http://localhost:9080/wbe/tools/test_javascript.html. You can use this tool to help validate your JavaScript.

Step 7: Define mapping from intermediate objects to actions

Next, you need to define how the actions are constructed from intermediate objects and the mapping from the intermediate object fields to the action fields.

  1. In the Touchpoints pane, select Buy Ack => TradeOut.
  2. On the right, expand StockID, as shown in Figure 9.
    Figure 9. Map action object fields
    Map action object fields
  3. In the Definition section of the action, select Field as the Type, select Insert object field , and select TradeObject.StockID for the list of fields.
  4. Repeat the previous step for CustomerID, Key, Date, Quantity and Price. For each of these add the associated intermediate object field prefixed with TradeObject.
  5. Save the project by selecting File => Save Project. Name the project Trading.xml and exit the Design Data tool.

    Note: Make sure you save the Design Data definitions and close Design Data before you open the Design tool to define the business logic.


Define the business logic

This section describes the steps you need to complete to define the business logic using the Design tool. These steps are normally completed by a business analyst.

  1. Open the Trading.xml file.
  2. Create two filters.
  3. Define three interaction sets.

Note: Since the Design Data tool and the Design tool use the same file, it's a good practice to close one tool before opening the other.

Step 1: Start the Design tool and open Trading.xml

To get started, do the following:

  1. Select Start => All Programs => WebSphere Business Events v6.1 => Design to start the Design tool.
  2. Open the project by selecting, File => Open and specify Trading.xml. The objects you defined in the Design Data tool are shown, but you can't modify them.

Step 2: Create an After Buy filter

The first filter you need to create is an After Buy filter that checks whether the event it is applied to occurs within an hour of a Buy event. You'll apply this filter to a Sell event. To create the After Buy filter, do the following:

  1. Click the Filter button on the toolbar (or select Create => Filter from the menu). This creates a filter template in the editor.
  2. Specify After Buy Filter as the name and then select operator?. A list of available operators is shown. From the ContextOperator folder select Follows Within, as shown in Figure 10.
    Figure 10. Create the first filter
    Create the first filter

    The filter template is updated to show the selected operator and its arguments.

  3. Next, click the first operand?, then choose Select an event.
  4. A list of the events defined in the project displays, as shown in Figure 11. Select Buy.
    Figure 11. Select the event argument for the stream function
    Select the event argument
  5. Click the second operand? (after Within), (see Figure 11), and select Enter text.
  6. In the resulting dialog, specify 1 for the day and click OK.

    At this stage, the filter should look like Figure 12.

    Figure 12. After Buy filter
    After Buy filter

The filter you just created will be used by the Sell After Buy interaction set (which you'll define shortly) that will identify when a Sell event has occurred after a Buy event for the same stock and customer.

This simple and readable filter will work well enough. The only problem with it is the pairing of events. For example, let's say one Buy event is followed by three Sells, all for the same customer and stock and in the same day. With the filter as it's defined now, all three Sell events will pass the After Buy Filter, resulting in three SellAfterBuy actions being generated. However, what you really want is to have only one such situation being detected for each pair of buy and sell events.

To achieve this, you need to further refine the filter. You'll add a condition that says an event passes the filter if it follows a Buy within a day and there was a Buy event after the last SellAfterBuy action. The second and third Sell events in the sequence described above would then fail the filter, which is what you want. To add this condition to the filter, do the following:

  1. Click the filter icon on the second line and select Add a filter condition, as shown in Figure 13.
    Figure 13. Add a filter condition
    Add a filter condition
    A new template condition is added with an AND operator connecting the two.
  2. Now you need to fill in the arguments for the second filter condition. Click the icon next to the first operand? and choose Select a Predefined Function, then select ContextFunction => Event or Action Occurs, as shown in Figure 14.
    Figure 14. Select Event or Action Occurs
    Select Event or Action Occurs
  3. The filter changes to show the Occurrences of function. Click the operand? for Occurrences Of, then choose Select an event , then SellAfterBuy.
  4. Click operator? and from the list of NumericOperators select Is, as shown in Figure 15.
    Figure 15. Select the numeric operator
    Select the numeric operator
  5. Click the remaining operand?, select Enter Text and enter 0. The filter should now look like Figure 16.
    Figure 16. The After Buy filter with the first branch condition
    The After Buy filter with the first branch condition

Note the different symbols in the filter definition for events events symbol and for actions actions symbol.

The filter is nearly complete. It will return true for an event when:

  • The event follows a Buy event within a day.
  • There have been no SellAfterBuy actions.

To pair the Buy and Sell events, you need to add another condition to the filter that checks that the last Buy event has happened after the last SellAfterBuy action. This ensures that one Buy is not paired with multiple Sell events, which would cause repeated SellAfterBuy actions. To add this condition, complete the following steps:

  1. Click the second condition of the filter (the icon to the right of the first bracket, as shown in Figure 17), and select Branch this filter condition.
    Figure 17. Branch a filter condition
    Branch a filter condition
  2. In the resulting branch, select And and replace it with Or, as shown in Figure 18.
    Figure 18. Modify the boolean operator linking the filter conditions
    Modify the boolean operator
  3. Click the symbol after the first operand?, choose Select a predefined function, and select DateTimeFunction, then Last Occurrence Of. as shown in Figure 19.
    Figure 19. Select a DateTime function
    Select a DateTime function
  4. Click operand? and choose Select an Event, and select Buy.
  5. Click the first of the two remaining operator? fields, and select is After DateTime from the resulting list.
  6. Click the last remaining operand?, choose Select a Predefined Function, and select Last Occurrence Of.
  7. Choose Select an action and select SellAfterBuy. Figure 20 shows the final filter:
    Figure 20. After Buy filter - complete definition
    After Buy filter - complete definition

Step 3: Create a Speculative Customer filter

Now you need to create a Speculative Customer filter. This filter will evaluate to true for every third occurrence of the SellAfterBuySynEvent within a day.

The completed filter uses the Occurrences of This Event Within function. This function does not count the current instance of the event. Therefore, for the third occurrence of this event, the number of previous occurrences is two. You'll need to add one to compensate for this behavior.

To make the filter true for every third event, we'll use the fact that the result of the function is an integer and we can use the Business Events integer division functions div and mod. For example, for a number n: (n div 3 ) X 3 = n if and only if n is a multiple of 3.

The filter evaluates to true if and only if number of total occurrences (including the current one) is a multiple of 3. Figure 21 shows what the completed filter will look like:

Figure 21. Speculative Customer filter
Speculative Customer filter

To create the Speculative Customer filter, do the following:

  1. Click the Filter button in the toolbox, and enter Speculative Customer as the name in the template.
  2. First we'll build the right part of the filter, starting from operator Is.
    1. Click operator? and select NumericOperator =>Is. Then Click the icon to the right of the second operand? and choose Select a Predefined Function => NumericFunction => Plus.
    2. Click the icon to the right of the last operand?, select Enter text, then enter 1.
    3. Click the icon to the right of the operand? before Plus and choose Select a Predefined Function => ContextFunction => This Event Occurs Within.
    4. Complete the operand by clicking the icon next to operand? and selecting Enter text, then enter 1 for day. The filter show now look like Figure 22.
      Figure 22. Speculative Customer filter - partially completed
      Speculative Customer filter - partially complete
  3. For the left side of a filter, we'll use a similar approach. We'll build this part of the filter from right to left: select a predefined function from the menu for the operand, fill in the right side operand by entering text and repeat the process for the left side operand until the filter is complete, as follows:
    1. Click the icon to the right of operand? and choose Select a Predefined Function => NumericFunction => multiplied By.
    2. Click the right operand?, select Enter text and enter 3.
    3. Click the icon next to the left operand? and select Select a Predefined Function => NumericFunction => Divided by.
    4. Click the left operand?, select Enter text and enter 3.
    5. Click the icon next to the left operand?, then select Select a Predefined Function => NumericFunction => Plus.
    6. Click the operand and select Enter text, then enter 1.
    7. Finally, select Occurrences of this Event.

The Speculative Customer filter is now complete.

Step 4: Create interaction sets

Now you need to create the following interaction sets, which will use the filters you just created to make business decisions:

  • The Buy Acknowledgment rule states that on receipt of a Buy event a Buy Acknowledgment action will always be generated.
  • The Sell After Buy rule states that when a Sell event comes in and the After Buy filter is satisfied (that is, the Sell event comes within an hour of a Buy event for the same stock and customer), a SellAfterBuy action is generated. This policy is grouped by the TradeObject.key, which is the concatenation of the Customer ID and the Stock ID.
  • The Speculative Customer rule states that when a Sell After Buy event comes in that verifies the Speculative Customer filter (that is, there were more than two occurrences of this event for the same customer within 24 hours), the corresponding action is generated. The policy is related by Customer ID.

You'll create the interaction sets shown in Figure 23:

Figure 23. Interaction sets
Interaction sets

To build the first interaction set, do the following:

  1. Click Interaction Set in the Design tool (or select Create => Interaction Set from the menu).
  2. A template of the interaction block is created. Enter Buy Acknowledgment as the name.
  3. Click event? for In response to, and select Buy. This fills in the Always part of the policy.
  4. Click action? and select Buy Ack.
  5. Left-click anywhere in the area after the interaction set name (Buy Acknowledgment), and select Define context relationship from the menu.
  6. Select TradeObject.Key for the context ID, as shown in Figure 24).
    Figure 24. Define a context relationship
    Define a context relationship

Though the Buy acknowledgement interaction set does not need a context relationship, the counting of buying and selling events is done by customer and stock, and therefore the rule needs to have a context ID.

To build the second interaction set, do the following:

  1. As before, create a new interaction set and give it the name Sell After Buy.
  2. For the response event, select Sell.
  3. Left-click anywhere in the area after the policy name and select Define context relationship from the menu.
  4. Select TradeObject.Key as the stream ID.
  5. Next, add a filter condition to the policy. Click the filter icon at the beginning of the second line and select Add a filter, as shown in Figure 25.
    Figure 25. Add a filter to a policy
    Add a filter to a policy
  6. For the Where operator, select After Buy from the list of available filters.
  7. For Always, select Sell After Buy from the list of actions.
  8. Right-click the action space (the box that begins with Always) and select Add an action, then select the synthetic event SellAfterBuySynEvent.

Now you're ready to build the final interaction set. The steps to define this interaction set are identical to those for the Sell After Buy policy:

  1. Create a new interaction set and name it Speculative Customer.
  2. Select SellAfterBuySynEvent as the event in response to which the policy will be executed.
  3. Define a context relationship with TradeObject.CustomerID as its key by right-clicking next to interaction set name and selecting the desired context relationship.
  4. Right-click the interaction set and select Add a filter => Speculative Customer.
  5. Select the action to be executed if the filter is evaluated to true, in this case, Speculative Customer.

The WebSphere Business Events application is now complete! Save the project and exit the Design tool.


Deploy and run the application

In order to deploy and run the Business Events application you just built, you'll perform the following steps:

  1. Specify the connector information for events and actions. This is included in the deployment step because it is this information that needs to be changed in the subsequent parts of the series for integration with other IBM products.
  2. Start the Business Events run-time in WebSphere Application Server, if not already started.
  3. Deploy the Business Events application to the run-time.
  4. Enable history.
  5. Restart the Business Events run-time.
  6. Start the connector process.

Step 1: Specify connector information

Before testing the Business Events application, you need to specify the connector information for all events and actions. For simplicity, you can use use the File System Connector to do this.

  1. Start the Design Data tool and open the project.
  2. Expand Touchpoints and select Buy.
  3. Right-click and select Event Properties.
  4. On the Connection tab, click File System Connection, as shown in Figure 26.
  5. On the File Event Connection dialog, select Connector Packet as the Format, as shown in Figure 26.
  6. Select 1 for the Contact frequency (in minutes), and click Configure, as shown in Figure 26.
  7. In the Server dialog, specify the directory location where you'll put the event files, for example, C:\Business Events\test\Buy and a *.xml for the File Pattern, as shown in Figure 26. Make sure the folder you specified exists on your file system.
  8. Repeat these steps for the Sell event, specifying Connector Packet as the format, contact frequency as 1 minute, and C:\WBE\test\Sell as the directory.

    Note: You don't need to perform the steps for the SellAfterBuySynEvent <- SellAfterBuySynAction event because that event is generated internally by Business Events itself.

    Figure 26. Configure the file connector information for Buy and Sell events
    Configure file connector information

Now you need to perform similar configuration steps for actions:

  1. Right-click Buy Ack, and select Action properties.
  2. On the Connection tab of the Action Properties dialog, select File System Connector.
  3. Configure the server section with a different directory from that associated with the Buy and Sell events. For example c:\WBE\testactions. This is where Business Events outputs the generated actions. Make sure that the folder you specified exists on your file system.
  4. Specify a file pattern unique to this action. For example Buy*.xml. Specifying a different naming pattern for each type of action makes it easy to see at a glance what the Business Events output is.
  5. Repeat these steps for SellAfterBuy and SpeculativeCustomer, using the same file path (for example c:\WBE\testactions), but a different file pattern, such as sell*.xml and spec*.xml.
  6. Save the project.

Step 2: Start the Business Events run-time

To start the Business Events run-time, do the following:

  1. Select Start => IBM WebSphere => Application Server Network Deployment => Profiles => AppSrvr01 => Start Server.
  2. Open the WebSphere Application Server administrative console in a Web browser and log into it. For example, http://localhost:9060/ibm/console with a user name of admin.
  3. In the console, make sure the WBERuntime application is started, as shown in Figure 27.
    Figure 27. Make sure Business Events is running in the console
    Make sure Business Events is running
  4. Make sure that the database manager is started. If you are using Derby, invoke startNetworkServer.bat from <WBE Install>\WAS\derby\bin\networkServer.

Step 3: Deploy the Business Events application to the run-time

To deploy the Business Events application to the run-time, do the following:

  1. In the Design Data tool, select Tools => Repositories, and click Login.
  2. Specify a user name and password.
  3. You may need to specify a different port number (other than 9080) if the version of WebSphere Application Server you are using does not use the default port number.
  4. Press Ctrl+A to select all elements in the list of artifacts on the Project tab of the Repository dialog, then click Add in, as shown in Figure 28. This adds all the elements to the repository. Note that you may be asked again for your user name and password.
    Figure 28. The Repository view
    Repository view
  5. Click Close and exit the Design Data tool. Make sure to save the project.

Step 4: Enable history

Now that the project is deployed, you can enable the Business Events history feature. This enables the Business Events run-time to keep track of events, actions, filters, and interaction sets so that you can review what happens in Business Events when you send events.

  1. Select Start => IBM WebSphere Business Events v6.1 => Events => Properties.
  2. Specify wbe for both the user ID and password, and click Next, then Next again.
  3. In the Server Settings dialog, change Enable history from false to true.
  4. Click Save and exit.

Step 5: Restart the Business Events run-time

Repeat the steps in Step 2 to restart the Business Events run-time.

Step 6: Start the connector process

To start the connector process, run connector.bat (or .sh) from <WBE_install> \director\bin.


Test the application

Now let's look at the Business Events Buy and Sell events and test that the actions can be generated.

  1. Copy and paste the sample Buy event shown below into a file and save it as Buy_event.xml. Make sure that the file name matches the file connector pattern of Buy*.xml.
    <connector name="Trade System" version="2.2">
      <connector-bundle name="Buy" type="event">
        <connector-object name="TradeObject">
          <field name="CustomerID" type="String">Jamie Danny</field>
          <field name="StockID" type="String">IBM</field>
          <field name="Date" type="DateTime">2008-06-04T10:04:41Z</field>
          <field name="Quantity" type="Real">10</field>
          <field name="Price" type="Real">150</field>
        </connector-object>
      </connector-bundle>
      <system>TISMANA</system>
      <timestamp>2008-06-04T10:04:41Z</timestamp>
      <loginfo>Test values from WebSphere Business Events:Design Data</loginfo>
    </connector>
  2. Copy and paste the sample Sell event below into a file and save it as sell_event.xml. Again, make sure that the file name matches the file connector pattern of Sell*.xml.
    <connector name="Trade System" version="2.2">
      <connector-bundle name="Sell" type="event">
        <connector-object name="TradeObject">
          <field name="CustomerID" type="String">Jamie Danny</field>
          <field name="StockID" type="String">IBM</field>
          <field name="Date" type="DateTime">2008-06-04T10:07:15Z</field>
          <field name="Quantity" type="Real">9</field>
          <field name="Price" type="Real">150</field>
        </connector-object>
      </connector-bundle>
      <system>TISMANA</system>
      <timestamp>2008-06-04T10:07:15Z</timestamp>
      <loginfo>Test values from WebSphere Business Events:Design Data</loginfo>
    </connector>
  3. Copy the Buy event file to the location specified in the File connector, for example, c:\WBE\test\Buy.
  4. Wait for 1 minute (the polling interval specified in the connector properties). At this stage, the event file should disappear and a Buy Ack action should be generated in the directory specified in the action connector (for example, c:\WBE\testactions).
  5. Next send a Sell event for the same customer and stock. A Sell After Buy action should be generated.
  6. Send additional Buy and Sell events to Business Events to cause the Speculative Customer action to be generated.

Figure 29 shows sample output from c:\WBE\testactions with the action files generated from the testing.

Figure 29. Sample Business Events output using File Connector
Sample Business Events output using File Connector

Note: You can also send events directly to Business Events using the cmdline tool located in <WBE_install>\director\bin. To use the tool, run the following command: cmdline <Event file>.xml For example, you could issue the following command to send a Buy event to Business Events: cmdline c:\temp\Buy_event.xml.

Note: If you see the following message repeated many times in the connectors window:

FS Sending event: Sell
FS Sending event: Sell
.…

and you don't see the expected output action, make sure you completed step 5 in the Specify connector information section correctly. The Connector format must be set to connector packet for the event to be triggered correctly.

View reports with the Business Events monitor

You can also use the Business Events monitor to see what happened in Business Events when the events were processed. This was made possible when you enabled history. To use the Business Events monitor to view reports, do the following:

  1. Enter the following URL in a browser: http://localhost:9080 /wbe/common/login.jsp. Make sure to use the correct port number for your Application Server.
  2. Enter a user name and password and select Administrator from the Tool list, then click Login.
  3. Click the Reports icon at the top of the control panel.
  4. Select Actions by Touchpoint by time as the Report Type.
  5. Click the Generate Report icon to run the report. The report displays in a separate window. as shown in Figure 30. After viewing the list of actions, close the window.
    Figure 30. Sample output of Business Events monitor
    Sample output in Business Events monitor

By choosing different report types from the Reports view, you can view events, filters, policies, streams and intermediate objects that WebSphere Business Events used during its execution.


Summary

You've now learned how to build and run a Business Events application. In the remaining articles in this series, we'll use the example scenario and this applicaton to illustrate how other IBM products can provide events into Business Events and consume its actions.


Acknowledgments

The authors would like to thank Eric Erpenbach and James Taylor for their comments and feedback on this article.


Download

DescriptionNameSize
XML fileTradingSystem.zip3KB

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


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. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

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.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

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

 


All information submitted is secure.

Dig deeper into Business process management on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Business process management, WebSphere
ArticleID=342800
ArticleTitle=Business Event Processing with WebSphere Business Events, Part 2: Building a business events application
publish-date=10012008