Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camel Split list<MyObject> in header

Can I split list of my object? Like this Camel- Split List<MyObj> and process each java object - XML Config but, for header.

like image 655
Alexander Kazantsev Avatar asked Jan 11 '23 05:01

Alexander Kazantsev


1 Answers

Yes, you can:

from("direct:start")
    .split(simple("header.myHeader"))
    .log("Split: ${body}");

Tested with:

final ProducerTemplate template = context.createProducerTemplate();
template.sendBodyAndHeader("direct:start", "World!", "myHeader", Arrays.asList("a", "b", "c"));

Log:

INFO  Split: a
INFO  Split: b
INFO  Split: c
like image 134
Peter Keller Avatar answered Jan 17 '23 17:01

Peter Keller