12. Resequencer

12.1 Introduction

Related to the Aggregator, albeit different from a functional standpoint, is the Resequencer.

12.2 Functionality

The Resequencer works in a similar way to the Aggregator, in the sense that it uses the CORRELATION_ID to store messages in groups, the difference being that the Resequencer does not process the messages in any way. It simply releases them in the order of their SEQUENCE_NUMBER header values.

With respect to that, the user might opt to release all messages at once (after the whole sequence, according to the SEQUENCE_SIZE, has been released), or as soon as a valid sequence is available. Another option is to set a timeout, deciding whether to drop the whole sequence if the timeout has expired, and not all messages have arrived, or to release the messages accumulated so far, in the appropriate order.

12.3 Configuring a Resequencer with XML

Configuring a resequencer requires only including the appropriate element in XML.

A sample resequencer configuration is shown below.

<channel id="inputChannel"/>

<channel id="outputChannel"/>

<resequencer id="completelyDefinedResequencer" 
  input-channel="inputChannel" 
  output-channel="outputChannel" 
  discard-channel="discardChannel" 
  release-partial-sequences="true" 
  timeout="42" 
  send-partial-result-on-timeout="true" 
  reaper-interval="135" 
  tracked-correlation-id-capacity="99" 
  send-timeout="86420000"  /> 

1

The id of the resequencer is optional.

2

The input channel of the resequencer. Required.

3

The channel where the resequencer will send the reordered messages. Optional.

4

The channel where the resequencer will send the messages that timed out (if send-partial-result-on-timeout is false). Optional.

5

Whether to send out ordered sequences as soon as they are available, or only after the whole message group arrives. Optional (true by default).

6

The timeout (in milliseconds) for reordering message sequences (counted from the arrival of the first message). Optional.

7

Whether, upon the expiration of the timeout, the ordered group shall be sent out (even if some of the messages are missing). Optional (false by default).

8

The interval (in milliseconds) at which a reaper task is executed, checking if there are any timed out groups. Optional.

9

The capacity of the correlation id tracker. Remembers the already processed correlation ids, preventing the formation of new groups for messages that arrive after their group has been already processed (reordered or discarded). Optional.

10

The timeout for sending out messages. Optional.

[Note]Note
Since there is no custom behavior to be implemented in Java classes for resequencers, there is no annotation support for it.