Message sequencing

Use message sequencing to ensure that messages are delivered to the receiving application in a particular order.

IBM® Integration Bus provides support for adding sequence numbers to messages, and for reordering messages in the message flow based on their sequence number. Messages can arrive in any order and you can use the Sequence and Resequence nodes to reorder the messages into the required sequence.

In some applications, the ability to process messages in a specific order is important for maintaining the integrity of the workflow. For example, a series of debits and credits against a bank account must be processed in the order in which they took place, and patient records that are received, processed, and forwarded must be sent on in the order in which they arrived.

Messages arriving in the message flow might or might not contain sequence numbers. If messages without sequence numbers are received from an input source, you can preserve the order in which the messages are received by using a Sequence node to generate a monotonically increasing sequence number for each message in the sequence group. When each message arrives at the Sequence node, the sequence number is incremented and stored with the message in a location specified on the node.

Information about the state of in-flight messages is held on storage queues that are controlled by WebSphere® MQ, so you must install WebSphere MQ on the same computer as your integration node if you want to use the capabilities provided by the Sequence and Resequence nodes. For more information about using WebSphere MQ with IBM Integration Bus, see Installing WebSphere MQ.

The current sequence numbers for each active sequence group are stored on the following WebSphere MQ queues:
  • SYSTEM.BROKER.SEQ.GROUP
  • SYSTEM.BROKER.SEQ.NUMBER
For more information, see Sequence node.

When the input messages contain sequence numbers, whether they were added by the Sequence node or already defined in an integer field in the message, you can use a Resequence node to change the order of the messages in the message flow.

When messages arrive at the Resequence node, they are held in a storage queue until all previous messages in the sequence have been propagated and committed. When each message becomes the next one in the sequence, it is taken off the queue and propagated down the Out terminal. This sequence of events ensures that messages are kept in the correct order even when message processing fails.

By default, the storage queues used by the Resequence node are:
  • SYSTEM.BROKER.EDA.COLLECTIONS
  • SYSTEM.BROKER.EDA.EVENTS
However, you can use a Resequence configurable service to specify alternative queues to be used by the Resequence node. For more information about using the Resequence configurable service, see Configuring the storage of events for Resequence nodes.
You can configure the Resequence node to time out if a message in the sequence fails to arrive in a specified period of time, and you can specify how subsequent messages are processed if a message is missing. For example, you can configure the node so that:
  • The message sequence must always be maintained
  • Gaps are allowed in the message sequence but all other messages must remain in sequence
  • Occasional out-of-sequence messages are allowed

For information about how to configure the Resequence node for these scenarios, see Handling missing messages.

You can divide messages into sequence groups, which can be processed independently, allowing multiple sequences to be processed at the same time. For more information about sequence groups and duplicate message processing, see Sequence groups.

For more information about the way in which the beginning and end of sequences are controlled, see Starting a message sequence.