ResequencerThe Resequencer The following example shows how to reorder the messages so that they are sorted in order of the body() expression. That is messages are collected into a batch (either by a maximum number of messages per batch or using a timeout) then they are sorted in order and then sent out to their output. Using the Fluent Builders from("direct:a").resequencer(body()).to("mock:result"); So the above example will reorder messages from endpoint direct:a in order of their bodies, to the endpoint mock:result. Typically you'd use a header rather than the body to order things; or maybe a part of the body. So you could replace this expression with resequencer(header("JMSPriority"))
for example to reorder messages using their JMS priority. You can of course use many different Expression languages such as XPath, XQuery, SQL or various Scripting Languages. Using the Spring XML Extensions For further examples of this pattern in use you could look at the junit test case Using This PatternIf you would like to use this EIP Pattern then please read the Getting Started, you may also find the Architecture useful particularly the description of Endpoint and URIs. Then you could try out some of the Examples first before trying this pattern out. |