About this task
In this example task, the sequence is defined as starting
at sequence number 0 (which is the default) and finishing at sequence
number 8. The message flow is configured so that messages can arrive
out of order but cannot be propagated out of order, even if one of
the sequence numbers never arrives.
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 WebSphere MQ queue:
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_TASK1_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.
- When the message containing sequence number 8 is processed, the
sequence group is closed. Any new message in the same group that arrives
later causes a new group to be created.
- The next messages arrive on the RESEQUENCE_TASK1_IN1 queue:
<Doc><SeqNo>8</SeqNo></Doc>,<Doc><SeqNo>7</SeqNo></Doc>,<Doc><SeqNo>6</SeqNo></Doc>,
<Doc><SeqNo>5</SeqNo></Doc>,<Doc><SeqNo>4</SeqNo></Doc>,<Doc><SeqNo>3</SeqNo></Doc>,
<Doc><SeqNo>2</SeqNo></Doc>,<Doc><SeqNo>1</SeqNo></Doc>,<Doc><SeqNo>0</SeqNo></Doc>,
- The Resequence node
first receives the message containing sequence number 8. At this point,
the Resequence node creates
a new (default) sequence group. The message is the last one in the
sequence so it is not propagated but is stored internally.
- The Resequence node
then receives the rest of the messages up to and including sequence
number 0. All the messages are stored and none are propagated until
the first number in the sequence is received (in this case, sequence
number 0).
- When the message with sequence number 0 is received, it is propagated
down the message flow, followed by each of the other messages, in
order, until the final message (sequence number 8) is propagated.
At this point, the sequence group is closed again.