...
Code Block | ||
---|---|---|
| ||
<eip:content-enricher service="test:contentEnricher" endpoint="endpoint"> <eip:enricherTarget> <eip:exchange-target service="test:additionalInformationExtracter" /> </eip:enricherTarget> <eip:target> <eip:exchange-target service="test:myTarget" /> </eip:target> </eip:content-enricher> |
Resequencer
A resequencer re-orders incoming In-Only or Robust-In-Only exchanges and sends them synchronously to a targets service. Synchronous sending ensures that messages arrive in correct order at the target service. This component implements the Resequencer pattern.
It works on (continuous) streams of message exchanges using a timeout policy. It differs from Camel's resequencer as it doesn't make batch-reads of predefined (maximum) size although a capacity
parameter prevents the resequencer from running out of memory. If the maximum out-of-sequence time difference between messages in a message stream is known, the resequencer's timeout
parameter should be set to this value (milliseconds). In this case it is guaranteed that all elements of a stream are delivered in correct order to the target service. The lower the timeout
value is compared to the out-of-sequence time difference the higher is the probability for out-of-sequence messages sent by this resequencer. Large timeout
values should be supported by sufficiently high capacity
values.
For comparing elements of a sequence the resequencer component can be configured with a sequence element comparator. A default comparator is provided that compares message exchanges based on Long
sequence numbers. This comparator expects the sequence number to be the value of the org.apache.servicemix.eip.sequence.number
property of the exchanges's in
-NormalizedMessage. The name of the property can be customized in the comparator configuration (see below). You may also provide a custom comparator by implementing the SequenceElementComparator interface.
Code Block | ||||
---|---|---|---|---|
| ||||
<beans
xmlns:sample="http://www.example.org/resequencer"
xmlns:eip="http://servicemix.apache.org/eip/1.0">
<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 id="comparator" sequenceNumberKey="seqnum"/>
</beans>
|
A running example can be downloaded from here. In this example, a custom-coded message sender sends messages in "wrong" order to the resequencer. The resequencer re-orders these messages and (synchronously) sends them to a file sender-endpoint. The file sender-enpoint writes the messages (in proper order) to the work/output
directory.
Tips
ExchangeTarget
All patterns use the <exchange-target /> tag to specify the target of a JBI exchange.
This element has the following attributes:
...