One way to do this is to assemble the list of destinations in a header, then reference that. Here's a rough example:
.process( new Processor() { public void process(Exchange exchange) { Message in = exchange.getIn(); List<String> mediaList = ((YourPojo) in.getBody()).getMedia(); String destinations = ""; int i = 0; for (String media : mediaList) { if (i++ > 0) { destinations += ","; } destinations += "direct:" + media; } in.setHeader("mediaDestinations", destinations); } }) .recipientList(header("mediaDestinations")) This has a nice side-effect of making it really easy to debug by dropping a log statement before the recipientList. You could also use bean binding instead of a processor: .setHeader(method(new MyRouter(), "route(${body.media})")) with a class like: public class MyRouter { public String route(List<String> media) {...} // returns comma-seperated endpoints } Jakub On 19/01/15 18:01, James Green wrote: > You mean a class implementing Expression? > > On 19 January 2015 at 17:56, Claus Ibsen <claus.ib...@gmail.com> wrote: > >> You can use a method call expression (aka java bean) where you add the >> direct: prefix to the media headers. >> >> Or try look at groovy or something which may be able to prefix to a >> list. I think I have seen that done in fabric8 v1. >> >> >> On Mon, Jan 19, 2015 at 6:32 PM, James Green <james.mk.gr...@gmail.com> >> wrote: >>> .recipientList(simple("direct:${body.media}")) >>> >>> So media is a List<String> property where each entry has a media value: >>> "sms", "email", etc. >>> >>> What I get out of this is an exception (where "sms" is the only media): >>> >>> org.apache.camel.component.direct.DirectConsumerNotAvailableException: No >>> consumers available on endpoint: Endpoint[direct://%5Bsms%5D]. >>> >>> If I remove the direct: from the simple expression and place it directly >> in >>> the media property value it works fine. But then my POJO "knows" about >>> direct: prefixes. Not what I had hoped. >>> >>> Any ideas? I can't use transform() as the rest of the message needs to be >>> passed onwards. >>> >>> James >> >> >> -- >> Claus Ibsen >> ----------------- >> Red Hat, Inc. >> Email: cib...@redhat.com >> Twitter: davsclaus >> Blog: http://davsclaus.com >> Author of Camel in Action: http://www.manning.com/ibsen >> hawtio: http://hawt.io/ >> fabric8: http://fabric8.io/ >>