Configuring Java CAPS Business Processes

Defining Message Correlations

BPM provides the means for matching existing Business Process instances to messages that are arriving into a Business Process. Correlation keys are individual data values contained within both the incoming message and the BPM engine. When an arriving message contains a value that matches a configured correlation key, the unique Business Process instance associated with that value continues processing to the next step of the Business Process. You can perform the following tasks to define message correlation.

For an example of using message correlation, see Linking and Sequencing With Message Correlation.

Creating Correlation Keys

A correlation key is a value that you can define in a Business Process, like a purchase order number, that provides a way to associate and route information about specific Business Process instances. For asynchronous message exchange between components, you must implement correlation of the instance identification. An example of when you use asynchronous message exchanges is when you create a receive activity in the middle of a Business Process.

ProcedureTo create a correlation key

  1. In the Project Explorer, right-click the Business Process, and then click Properties.

  2. Click the Correlations tab.

  3. In the Correlation Keys section, click Create.

    The New Correlation Key dialog box appears.

  4. In the Name field, enter a name, or alias, for the correlation key.

  5. In the Select from Tree field, select a message type from the list to add to the alias. Select one or more correlation keys that comprise a unique identifier for a step in a Business Process.

  6. Click Add to save the new alias to the Selected Alias List.


    Note –

    The value for the Type field is automatically populated.


  7. Click OK.

Editing Correlation Keys

Once you create a correlation key, or one is created for you, you can modify the key by adding or removing message types.

ProcedureTo edit a correlation key

  1. In the Project Explorer, right-click the Business Process, and then click Properties.

  2. Click the Correlations tab.

  3. In the Correlation Keys section, click the key you want to modify and then click Edit.

  4. Do either of the following:

    • In the Select from Tree field, select a message type from the list to add to the alias, and then click Add.

    • In the Selected Alias List, select a message type you want to remove, and then click Remove.

  5. Click OK.

Deleting Correlation Keys

Once you create a correlation key, or one is created for you, you can delete the key if it is no longer used. Some correlation keys cannot be removed.

ProcedureTo delete a correlation key

  1. In the Project Explorer, right-click the Business Process, and then click Properties.

  2. Click the Correlations tab.

  3. In the Correlation Keys section, select the key you want to delete, and then click Delete.

  4. Click OK.

Adding Correlation Sets

Correlation sets are groups of properties (correlation keys) shared by all messages in the group. A correlation set matches messages and conversations with a Business Process instance. For example, you might want to assign a purchase order number and an invoice number to a transaction so all information about the purchase and payment are associated.


Note –

When naming correlation sets, use unique names. Duplicate correlation set names cause indexing problems in the monitoring and recovery database. Consider including the Business Process name in the correlation set name to ensure uniqueness.


ProcedureTo add a correlation set

  1. Click the Correlations tab.

  2. In the Correlation Set section, click Create.

    The New Correlation Set dialog box appears.

  3. In the Name field, enter a name for the new correlation set.

  4. In the Select from List box, select the correlation keys you want to add to the correlation set. Use the Ctrl key to select multiple keys.

  5. Click the right-arrow button to move your selections to the correlation set.

  6. Click OK.

Editing Correlation Sets

Once you create a correlation set, or one is created for you, you can modify the correlation set by adding or removing correlation keys.

ProcedureTo edit a correlation set

  1. In the Project Explorer, right-click the Business Process, and then click Properties.

  2. Click the Correlations tab.

  3. In the Correlation Sets section, click the correlation set you want to modify and then click Edit.

    The Edit Correlation Set dialog box appears.

  4. Do either of the following:

    • In the Select from List, select a key you want to add, and then click Add.

    • In the Selected Keys for correlation set list, select a key you want to remove, and then click Remove.

  5. Click OK.

Deleting Correlation Sets

Once you create a correlation set, or one is created for you, you can delete the set if it is no longer used. Some correlation sets cannot be removed.

ProcedureTo delete a correlation set

  1. In the Project Explorer, right-click the Business Process, and then click Properties.

  2. Click the Correlations tab.

  3. In the Correlation Sets section, select the set you want to delete, and then click Delete.

  4. Click OK.

Binding Correlation Sets to Receive Activities

When you use one or more correlation sets within a Business Process, you must bind the sets to a receive activity and initialize the sets before they are used. This ensures that the correlation set is created in memory before it is used.

If you choose to initialize a set within an activity, you must either choose to use both Business Process attributes or identify which Business Process attribute to use.

ProcedureTo bind a correlation set to an activity

  1. In the Business Process Designer, select an activity.

  2. On the Business Process Designer toolbar, click Show Property Sheet.

  3. Click in the Use Correlations field, and then click the ellipsis (...).

    The Use Correlations dialog box appears.

  4. Click Add.

    The Assign Correlation Set dialog box appears.

  5. In the Select From List panel, select the names of the correlation sets you want to bind to the activity, and then click Add.

  6. Click OK.

  7. On the Use Correlations dialog box, click OK.

Linking and Sequencing With Message Correlation

Linking and Sequencing

You can impose conditions on a set of messages, process a group of messages together, or make a decision contingent upon the receipt or non-receipt of all messages of a certain type. By using BPM’s linking and sequencing capabilities, you can sort messages into separate containers and execute Business Rules on containers of messages rather than on the individual messages. A container’s link identifier (a correlation ID) differentiates containers and links the messages identified with that container.

When BPM retrieves a message, it correlates the received message to a Business Process instance. If BPM finds a correlation match, it stores the message in the container for that Business Process. Otherwise, it instantiates a new Business Process instance.

For example, a Business Process handles HL7 messages that have been broken up with a continuation pointer. The Business Process contains logic that detects this condition and defers processing the HL7 message until it has been completely reassembled. The container qualifies as “full” when all HL7 messages for the same continuation pointer have been received.

Correlation Example

In this example, the Business Process expects to receive three course grades in order to qualify a student for further studies. The courses are Math, English, and Computer Science. Each message contains the course grade, the course type, and a correlation ID to indicate where the message belongs.

A new message arrives with a correlation ID of 101. First, BPM correlates the message to see if there is a match on the newly arrived message. Since this is the first message, there is no match and a new instance is created. The second message has a correlation ID of 101. BPM correlates the message and finds a match, so the message is forwarded to the same business instance as the first message. The third message has a Correlation ID of 102. Because there is no correlation match, the message is forwarded to a new business instance. This continues until a grade is received for each course type.

This process can continue depending on conditions you set based on count or time expiration. A sample Business Process is shown below for message correlation. The main Business Process uses a File eWay to read a DTD-based message, unmarshal the message, and then invoke a sub-process passing in the unmarshaled message.

The sub-process receives the unmarshaled message using an event-based decision and timer events in a while loop. The while loop continues until either a specified count has been reached or the time has expired. When messages are received, they are stored in containers until the requirements are met.

The timer event sets an expiration time. If time expires, the loop condition is set to false to terminate the loop. If a message is received, the message counter is incremented and, if the maximum number of messages have been received, the loop is terminated. When processing is complete, the date is written to a file.