Sample 703: Introduction to Message Resequencing Processor
<definitions xmlns="http://ws.apache.org/ns/synapse">
<sequence name="next_seq">
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService">
<suspendOnFailure>
<errorCodes>-1</errorCodes>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
</address>
</endpoint>
</send>
</sequence>
<sequence name="main">
<in>
<log level="full"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="OUT_ONLY" value="true"/>
<store messageStore="MyStore"/>
</in>
<out>
<send />
</out>
<description>The main sequence for the message mediation</description>
</sequence>
<messageStore name="MyStore"/>
<messageProcessor
class="org.apache.synapse.message.processors.resequence.ResequencingProcessor"
name="ResequencingProcessor" messageStore="MyStore">
<parameter name="interval">10000</parameter>
<parameter name="seqNumXpath" xmlns:m0="http://services.samples" expression="substring-after(//m0:placeOrder/m0:order/m0:symbol,'-')"/>
<parameter name="nextEsbSequence">next_seq</parameter>
</messageProcessor>
</definitions>
Objective
Introduction to Message Resequencing Processor
Executing the Client
Execute the Client with commands :
ant stockquote -Dtrpurl=http://localhost:8280/ -Dmode=placeorder -Dsymbol=WSO2-2
ant stockquote -Dtrpurl=http://localhost:8280/ -Dmode=placeorder -Dsymbol=WSO2-3
ant stockquote -Dtrpurl=http://localhost:8280/ -Dmode=placeorder -Dsymbol=WSO2-1
You have to use different sequence numbers for WSO2-#. According to configuration
sequence number should be seperated with a hyphen mark.
When you execute the client the message will be dispatched to the main sequence.
In the Main sequence store mediator will store the placeOrder request message in
the 'MyStore' message store.
Message Processor will consume the messages and forward to the 'next_seq' sequence
according to sequence number order.
You will see that the Axis2 server has recieved the messages in sequence number order
Following logic is used to decide the initial sequence number.
- When starting Synapse Resequencing Processor checks the attached message store for any messages.
If any messages found, select the minimum sequence number as the initial sequence number. Else continue without selecting initial sequence number.
- If initial sequence number is selected at the start up, continue sending messages to the given sequence.
Otherwise waits for required number of messages to come with in a certain timeout.
- If the required number of messages are received, select initial sequence number from those and do further resequencing.
If required number of messages are not received with in timeout, select the initial sequence number from available messages in the store.
Back to Catalog