Starting a message sequence

The start of a message sequence is determined by the Start of sequence definition property on the Resequence and Sequence nodes.

Using a Resequence node

When you use the Resequence node to reorder messages in a message flow, you use the Start of sequence definition property on the Resequence node to define how the reordered message sequence will start. You can specify the starting sequence number in one of the following ways:

As a literal number
Select Literal to specify a literal sequence number, which can be any positive or negative numeric value in the range -9223372036854775807 to 9223372036854775807. When a message with the specified sequence number arrives, it is identified as the first message in the sequence and the messages are propagated.
Using the smallest number received
Select Automatic and specify the length of time (in seconds) during which the node collects messages, before it identifies the message that contains the smallest sequence number. When the smallest number has been determined, that sequence number becomes the first in the message sequence.
For example, assume that you have a Resequence node with the following properties:
  • Path to sequence number property with a value of /doc/seq
  • Path to sequence group identifier property with a value of /doc/grp
  • Start of sequence definition property set to Automatic with a value of 5. This value means that, for any new group, the Resequence node collects messages for 5 seconds before determining the starting sequence number.
  • End of sequence definition property set to Automatic with a value of 60. This value means that, for any new group, the Resequence node waits for 60 seconds before determining the ending sequence number.
The following messages are received by the Resequence node:
<doc><grp>a<grp><seq>5</seq></doc>
<doc><grp>a<grp><seq>4</seq></doc>
<doc><grp>a<grp><seq>3</seq></doc>
<doc><grp>a<grp><seq>2</seq></doc>
<doc><grp>b<grp><seq>0</seq></doc>
<doc><grp>b<grp><seq>2</seq></doc>
At this point, the automatic period for the start of sequence expires (5 seconds), then the following messages are received:
<doc><grp>a<grp><seq>6</seq></doc>
<doc><grp>b<grp><seq>3</seq></doc>
For group a, the following messages are propagated to the Out terminal after 5 seconds:
<doc><grp>a<grp><seq>2</seq></doc>
<doc><grp>a<grp><seq>3</seq></doc>
<doc><grp>a<grp><seq>4</seq></doc>
<doc><grp>a<grp><seq>5</seq></doc>
<doc><grp>a<grp><seq>6</seq></doc>
For group b, the following message is propagated to the Out terminal after 5 seconds:
<doc><grp>b<grp><seq>0</seq></doc>
No more messages are received before a missing message timeout occurs, at which point the following messages are propagated to the Expire terminal:
<doc><grp>b<grp><seq>2</seq></doc>
<doc><grp>b<grp><seq>3</seq></doc>
Using predicate set on the Resequence node
Select Predicate and specify an XPath expression to calculate whether the message is the first in the sequence. The predicate evaluates to either True or False, and messages continue to be collected while the expression evaluates to False. When the expression of a message is evaluated to True, it indicates that the message is the first in the sequence.
For example, you might specify the following XPath expression:
/Employee/EmpStartSeq="10"
When the input message field EmpStartSeq contains the value 10, the start of sequence predicate is evaluated to True, and the message is identified as the first in the sequence:
<Employee>
 <EmpStartSeq>10</EmpStartSeq>
</Employee>
Typically, the XPath expression evaluates to a Boolean; however, if other data types are returned, the predicate is determined in the following way:
Table 1.
Returned data type True False
Boolean True False
Numeric Any non-zero value 0 or 0.0
String Any string matching true (case-insensitive) Any string not matching true (case insensitive)
NodeSet Never Always

When a message evaluates the expression to True (and is therefore identified as the start of the sequence), the node checks that the message has the smallest sequence number collected up to that point. If messages are found with lower sequence numbers, an exception is thrown.

When the first message that evaluates to true has been processed successfully, the XPath expressions of subsequent messages are not checked. If a message arrives with a lower sequence number than the message that was identified as the start of the sequence, an exception is thrown.

Using a Sequence node

When you use the Sequence node to add sequence numbers to messages in the message flow, you use the Start of sequence definition property to specify a literal number that is to be used as the starting sequence number. The value can be any positive or negative integer in the range -9223372036854775807 to 9223372036854775807.

The Sequence node allocates a monotonically increasing sequence number for each input message that arrives at the node, starting with the sequence number that you define in the Start of sequence definition property. However, this value can be overridden by the value of the StartOfSequenceNumber field in the LocalEnvironment of the incoming message. For example: InputLocalEnvironment.Sequence.StartOfSequenceNumber = 10.