On Thu, Jun 21, 2012 at 1:28 PM, PJ Walstroem <walst...@hotmail.com> wrote:
> hello helpful forum,
>
> I have the following XML
> <x myAttr="123">
>   <y>
>      ....data 1...
>   </y>
>   <y>
>      ....data 2...
>   </y>
> </x>
>
> and the following setup
> .split().tokenizeXML("y")
>
> I have a couple of questions
> *1*) I would like to split this into two messages:
>
> <x myAttr="123">
>   <y>
>      ....data 1...
>   </y>
> </x>
>
> and
>
> <x myAttr="123">
>   <y>
>      ....data 2...
>   </y>
> </x>
>
> How could I achieve this? My first thought was that split().tokenizeXML("y",
> "x") would do the trick, but apparently not.
> I assume the answer is that I have to write my own aggregation strategy, but
> then there seems to be no way to use tokenizeXML. The only way to tell split
> to use an AggregationStrategy is to use split(expression,
> aggregationStrategy).
>

The splitter can configure the strategy from the DSL eg using
aggregationStrategy as show:
.split().tokenizeXML("person").aggregationStrategy(new MyStrategy())

If you want 2 outgoing messages, you should use both the splitter and
the aggregator
accordingly to the EIP patterns.

The aggregation strategy on the splitter will combine all the back
into a single outgoing message.
PS: You could then in theory split that message again, if your custom
aggregation strategy build a List<Object> that
contains the 2 messages you want.




> *2*) How could I prevent the original message to pass through the split?
> From my example, I would like to get only the two splitted messages, not the
> original one as an extra bonus. I can see that this is mentioned on
> http://camel.apache.org/splitter.html, but I do not see how the
> request/reply sample explains this...
> In what cases would the original message be interesting? I can not see that
> the Splitter EIP advocates such a behaviour?
>
> any help is highly appreciated
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Split-how-to-include-parents-in-XML-and-prevent-original-message-tp5714836.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to