Message sequencing scenario 1

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 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 IBM MQ queue:

Procedure

  1. Create a message flow called Resequence_Task1, containing an MQInput node, a Resequence node, and an MQOutput node.
    For more information about how to do this, see Creating a message flow.
  2. Connect the Out terminal of the MQInput node to the In terminal of the Resequence node.
  3. 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.
  4. Set the following properties of the MQInput node:
    1. On the Basic tab, set the Queue name property to RESEQUENCE_TASK1_IN1
    2. On the Input Message Parsing tab, set the Message domain property to XMLNSC.
  5. On the Resequence node, set the following properties on the Basic tab:
    1. Set the Path to sequence number property to $Root/XMLNSC/Doc/SeqNo
    2. Set the End of sequence definition property to Literal with a value of 8.
  6. On the MQOutput node, set the Queue name property (on the Basic tab) to RESEQUENCE_TASK1_OUT1.
  7. Save the message flow.

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.

  1. 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>,
  2. 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.
  3. 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.
  4. 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.
  5. 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>,
  6. 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.
  7. 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).
  8. 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.