Message sequencing scenario 2
Change the sequence of messages received from WebSphere® MQ, so that they are propagated in the correct order using a sequence number defined in an XML message.
Before you begin
Read the concept topic about Message sequencing.
About this task
In this example task, the sequence is defined as starting at sequence number 0 (which is the default) and finishing when it has received no new messages in the group for 60 seconds. The message flow is configured so that messages can arrive out of order but the Resequence node attempts to propagate them in the correct order. If a required message in the sequence fails to arrive for 10 seconds, the Resequence node skips the missing message and propagates the next message in the sequence, even though it is now out of order.
The following steps show how to write a message flow that can receive the XML document from WebSphere MQ, reorder the messages based on a sequence number in an XML message (in this example the path $Root/XMLNSC/Doc/SeqNo is used) and write it to a IBM MQ queue:
Procedure
Results
Message processing in the message flow:
This section describes the way in which the Resequence node processes the messages that enter the message flow:
- The following messages arrive on the WebSphere MQ queue RESEQUENCE_TASK2_IN1:
<Doc><SeqNo>0</SeqNo></Doc>,<Doc><SeqNo>1</SeqNo></Doc>,<Doc><SeqNo>2</SeqNo></Doc>, <Doc><SeqNo>3</SeqNo></Doc>,<Doc><SeqNo>4</SeqNo></Doc>,<Doc><SeqNo>5</SeqNo></Doc>, <Doc><SeqNo>6</SeqNo></Doc>,<Doc><SeqNo>7</SeqNo></Doc>,<Doc><SeqNo>8</SeqNo></Doc>,
- The Resequence node first receives the message with sequence number 0. The Resequence node creates a new sequence group to manage the reordering process; the new sequence group is a default group because no sequence group has been defined in the message. The message (with sequence number 0) is the first one in the sequence, so it is propagated to the Out terminal.
- The Resequence node then receives the rest of the messages up to and including sequence number 8, and propagates them in the order in which they arrived. Each message is stored before it is propagated, and a different transaction is used for propagating the messages downstream from the Resequence node.
- Sixty seconds elapse and the sequence group is closed.
- The next messages arrive on the WebSphere MQ queue RESEQUENCE_TASK2_IN1:
<Doc><SeqNo>0</SeqNo></Doc>,<Doc><SeqNo>3</SeqNo></Doc>,<Doc><SeqNo>2</SeqNo></Doc>, <Doc><SeqNo>4</SeqNo></Doc>,<Doc><SeqNo>6</SeqNo></Doc>,<Doc><SeqNo>7</SeqNo></Doc>,
- The Resequence node first receives the message containing sequence number 0. At this point, the Resequence node creates a new (default) sequence group and propagates the message with sequence number 0 to the Out terminal.
- The next message contains sequence number 3, which is out of sequence. The Missing message timeout property is set on the Resequence node with a value of 10 seconds, and the timer starts.
- Sequence number 2 arrives, which is still not the next required message but it is lower than the lowest message currently stored, so the missing message timer is reset.
- The Resequence node then receives the rest of the messages, all of which have a higher sequence number than 2, so they are stored but not propagated. The missing message timer is not reset this time because each number is later in the sequence than number 2.
- Sequence number 1 fails to arrive during the specified period, and after 10 seconds the timeout period expires.
- The Resequence node propagates all the messages that are stored, starting with the lowest sequence number (in this case, 2) followed by all other messages up to the next missing number in the sequence (in this case, messages with sequence numbers 3 and 4). Messages 2, 3, and 4 are propagated to the Expire terminal.
- The Resequence node is moved to an unordered state for this sequence group, and will not propagate any messages in this group to the Out terminal. The Resequence node remains in the unordered state for this sequence group until the group expires and is closed.
- When another 10 seconds has passed, the missing message timer expires again and messages 6 and 7 are propagated to the Expire terminal. At this point there are no more missing messages so the missing message timer is not restarted.
- The group expiry timer is started and the group is closed after 60 seconds have passed. The group expiry timer is never started when a missing message timer is running.