Reordering messages in a message flow

When messages entering a message flow contain sequence numbers and a group ID, you can use the Resequence node to re-establish the sequential order of the messages before propagating them through the message flow.

Before you begin

Read the concept topic about Message sequencing.

Ensure that each message contains a monotonically increasing sequence number.

About this task

The sequence number might have been added to the message by the Sequence node or it might be another integer field in the message.

When the Resequence node receives an input message, it propagates the message only if it is the next one in the sequence. If the message is not next in the sequence, the Resequence node stores it until further messages arrive that allow the node to correct the sequence, at which point the node propagates the stored message. If a message fails to arrive, preventing the Resequence node from completing the sequence, the remaining messages are processed according to the way in which the Resequence node has been configured. For more information about this configuration, see Handling missing messages.

A transaction break occurs at the Resequence node. When a message is delivered to the Resequence node, control is returned to the previous node in the message flow. All messages that are propagated from the Resequence node are propagated in a new transaction, even if the sequence is complete. For more information, see Resequence node.

The message sequence is preserved when the integration node is restarted. If the Persistent option is selected on the Advanced tab of the Resequence node, the sequence is also preserved when the queue manager is restarted.

The following steps show how to create a message flow that enables you to re-establish the sequential order of the messages in a sequence group:

Procedure

  1. Switch to the Integration Development perspective.
  2. Create a message flow containing an MQInput node, a Resequence node, and an MQOutput node.
  3. Connect the Out terminal of the MQInput node to the In terminal of the Resequence node.
  4. Connect the Out terminal of the Resequence node to the In terminal of the MQOutput node.
    Message flow consisting of MQInput, Resequence, and MQOutput nodes.
  5. On the MQInput node, specify the source of input messages for the node by setting the Queue name property (on the Basic tab) to the name of an IBM MQ queue, from which the MQInput node retrieves messages. For example: RESEQ.TASK1.IN1.
  6. Set the following properties of the Resequence node:
    1. On the Basic tab, set the following properties:
      • Set the Path to sequence number property to the location of the sequence number in the message. For example, $InputBody/doc/seq. The sequence number is also set in the local environment, with the LocalEnvironment.Sequence.Number variable.
      • Set the Path to sequence group identifier property to the location of the sequence group identifier in the message. For example, $InputBody/doc/grp. The sequence group identifier is also copied to the local environment, with the LocalEnvironment.Sequence.Group variable.
      • Set the Start of sequence definition property to the first sequence number in the group. For example, select Literal with a value of 0.
      • Set the End of sequence definition property to Automatic with the required timeout value; for example, 60. This value specifies that the sequence group is closed automatically when the message queue in the node has been empty for 60 seconds. The end of sequence message is indicated in the local environment by the LocalEnvironment.Sequence.End variable, which takes a Boolean value.
      • Set the Missing message timeout property to 10. This value specifies that the Resequence node will wait for a missing message for 10 seconds before propagating subsequent messages in the sequence group to the Expire terminal. When the subsequent message is propagated, the sequence numbers of any missing (timed-out) messages are copied to the local environment, as LocalEnvironment.Sequence.Missing variables.
  7. On the MQOutput node, set the Queue name property (on the Basic tab) to the name of a WebSphere® MQ queue to which the MQOutput node sends messages. For example: SEQ.TASK1.OUT1.
  8. Save your message flow.