Alexander Kazantsev
Alexander Kazantsev

Reputation: 340

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.

Upvotes: 5

Views: 6057

Answers (1)

Peter Keller
Peter Keller

Reputation: 7636

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

Upvotes: 11

Related Questions