LibraryLink ToToggle FramesPrintFeedback

Resequencer

The resequencer pattern enables you to resequence messages according to the sequence number stored in an NMR property. The ServiceMix EIP resequencer pattern maps to the FUSE Mediation Router resequencer configured with the stream resequencing algorithm.


The sequence of messages emitted from the resequencer is determined by the value of the sequence number property: messages with a low sequence number are emitted first and messages with a higher number are emitted later. By default, the sequence number is read from the org.apache.servicemix.eip.sequence.number property in ServiceMix. But you can customize the name of this property using the eip:default-comparator element in ServiceMix.

The equivalent concept in FUSE Mediation Router is a sequencing expression, which can be any message-dependent expression. When migrating from ServiceMix EIP, you would normally define an expression that extracts the sequence number from a header (a FUSE Mediation Router header is equivalent to an NMR message property). For example, to extract a sequence number from a seqnum header, you could use the simple expression, header.seqnum.

The following example shows how to define a resequencer using the ServiceMix EIP component.

<eip:resequencer
  service="sample:Resequencer"
  endpoint="ResequencerEndpoint"
  comparator="#comparator"
  capacity="100"
  timeout="2000">
  <eip:target>
    <eip:exchange-target service="sample:SampleTarget" />
  </eip:target>
</eip:resequencer>

<!-- Configure default comparator with custom sequence number property -->
<eip:default-comparator xml:id="comparator" sequenceNumberKey="seqnum"/>

The following example shows how to define an equivalent route using FUSE Mediation Router XML configuration:

<route>
  <from uri="jbi:endpoint:sample:Resequencer:ResequencerEndpoint"/>
  <resequencer>
    <simple>header.seqnum</simple>
    <to uri="jbi:service:sample:SampleTarget" />
    <stream-config capacity="100" timeout="2000"/>
  </resequencer>
</route>

The following example shows how to define an equivalent route using the FUSE Mediation Router Java DSL:

from("jbi:endpoint:sample:Resequencer:ResequencerEndpoint").
    resequencer(header("seqnum")).
    stream(new StreamResequencerConfig(100, 2000L)).
    to("jbi:service:sample:SampleTarget");