Configuring Java CAPS Business Processes

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.