[CONF] Apache Camel: Splitter (page edited)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[CONF] Apache Camel: Splitter (page edited)

Dhiraj Bokde (Confluence)

Splitter has been edited by Jonathan Anstey (Oct 06, 2008).

(View changes)



The Splitter from the EIP patterns allows you split a message into a number of pieces and process them individually


The following example shows how to take a request from the queue:a endpoint the split it into pieces using an Expression, then forward each piece to queue:b

Using the Fluent Builders

RouteBuilder builder = new RouteBuilder() {
    public void configure() {

The splitter can use any Expression language so you could use any of the Languages Supported such as XPath, XQuery, SQL or one of the Scripting Languages to perform the split. e.g.


Using the Spring XML Extensions

<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
    <from uri="seda:a"/>
      <to uri="seda:b"/>

For further examples of this pattern in use you could look at one of the junit test case

Parallel execution of distinct 'parts'

If you want to execute all parts in parallel you can use special notation of splitter() with two arguments, where the second one is a boolean flag if processing should be parallel. e.g.

XPathBuilder xPathBuilder = new XPathBuilder("//foo/bar"); 
from("activemq:my.queue").splitter(xPathBuilder, true).to("activemq:my.parts");

Using This Pattern

If 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.