Resequencers
An important characteristic of a messaging system is the order of the messages. Although in some cases, the ordering defeats the performance, it is sometimes mandated by some applications. For example, when a message publisher comes back after a crash, the replay of the messages should appear in an orderly fashion.
The Resequencer component has the ability to order the incoming messages. For example, if 10 messages are published to a channel but in the wrong order, the consumer plugged in after the Resequencer does its work will receive all of them in a predefined sequence, e.g., message 1, message 2, etc.
The Resequencers work on the SEQUENCE_NUMBER header field to track the
sequences. Say a message numbered 8 (out of 10 child messages) is the
first to arrive; the Resequencer does not publish this message, since
message number 1 (the first SEQUENCE_NUMBER) or messages numbered 2 through
7 have not arrived. Message 8 (along with any other out-of-order messages)
is hence stored either in-memory or in the database until the entire set
has arrived and is reordered. The exception is if you set a release-partial-sequences flag to
true, which would publish the sequences as soon as they
are gathered, rather than waiting for the whole group.
The resequencer element in the
integration namespace is used to define a Resequencer as shown in the
following snippet:
<int:resequencer input-channel="all-in-reseq-channel" output-channel="reseq-channel" release-partial-sequences="true"> </int:resequencer> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access