SplitterThe Splitter ExampleThe 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() { from("seda:a").splitter(bodyAs(String.class).tokenize("\n")).to("seda:b"); } }; 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. from("activemq:my.queue").splitter(xpath("//foo/bar")).to("file://some/directory") Using the Spring XML Extensions <camelContext id="buildSplitter" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="seda:a"/> <splitter> <recipients> <bodyAs class="java.lang.String"/> <tokenize token=" "/> </recipients> </splitter> <to uri="seda:b"/> </route> </camelContext> For further examples of this pattern in use you could look at one of 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. |