Here an example what I unterstood.
Jan
package de.materne.camel;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.camel.EndpointInject;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
public class IterateOverMapTest extends CamelTestSupport {
@EndpointInject(uri="mock:foo")
private MockEndpoint foo;
@EndpointInject(uri="mock:bar")
private MockEndpoint bar;
@Test
public void test() throws InterruptedException {
Map<String, String> data = new HashMap<>();
data.put("foo.suffix", "One");
data.put("foo.anotherSuffix", "Two");
data.put("bar.suffix", "Three");
foo.expectedMessageCount(2);
bar.expectedMessageCount(1);
template().sendBody("direct:in", data);
assertMockEndpointsSatisfied(1, TimeUnit.SECONDS);
}
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:in")
// for splitting, we need an
Iterable
.transform(simple("${in.body.entrySet()}"))
// now simple split over the
Iterable
.split(body())
// content based routing on key
prefix
.choice()
.when(simple("${in.body.key()} starts with 'foo'"))
.to("mock:foo")
.when(simple("${in.body.key()} starts with 'bar'"))
.to("mock:bar")
.otherwise()
.to("mock:end")
;
}
};
}
}
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]]
> Gesendet: Montag, 24. Oktober 2016 11:53
> An: [email protected]
> Betreff: Re: Dynamic routing based on collection values
>
> Thanks will tr the split method. Is there any example available on the
> web to split the collection? I searched but couldn't find much help.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Dynamic-routing-based-on-collection-
> values-tp5789157p5789169.html
> Sent from the Camel - Users mailing list archive at Nabble.com.