Java 8 and Apache Camel 2.19.5 here. I have the following bean processors:
@Component("foobarResolver")
public class FoobarResolver {
public List<Foobar> resolve(Fizzbuzz fizzbuzz) {
List<Foobar> foobars = new ArrayList<Foobar>();
// Use some logic in here to make the fizzbuzz populate the foobars list.
return foobars;
}
}
@Component("fizzbuzzProcessor")
public class FizzbuzzProcessor {
public FizzbuzzOutput process(Fizzbuzz fizzbuzz) {
// Blah whatever
}
}
And the following Camel route:
<route id="fizzbuzzHandler">
<!-- XML '<fizzbuzz>' messages get sent here by an upstream process -->
<from uri="activemq:fizzbuzzes"/>
<!-- Use XStream to deserialize the XML into a 'Fizzbuzz' POJO instance -->
<unmarshal ref="xs"/>
<split>
<method ref="bean:foobarResolver"/>
<to uri="activemq:analyze"/>
</split>
<!-- Now assuming our body is once again the Fizzbuzz we can just continue as normal... -->
<!-- Process the fizzbuzz -->
<to uri="bean:fizzbuzzProcessor"/>
<!-- Send fizzbuzzProcessor's output to 'output' queue -->
<to uri="activemq:output"/>
</route>
So as you can see, the deserialized Fizzbuzz instance gets sent to the FoobarResolver bean processor, which turns that instance into a List<Foobar> and then sends each Foobar off to the analyze queue, one by one. At least thats the intention of my design anyways!
What I'm curious is: after the split, what does the exchange body become? Does it "revert" back to the Fizzbuzz (which is what I want), or is the exchange body now the List<Foobar> produced by the FoobarResolver (which is NOT what I want)? If the body is now the List<Foobar>, how could I reconfigure things so that the FizzbuzzProcessor receives a Fizzbuzz instead?
It appears to revert to the pre-split body:
Yields: