You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kiranreddykasa <ki...@fss.co.in> on 2013/02/13 10:12:49 UTC
building route in java dsl
Can anyone tell me how to build camel route dynamically in dsl.
I am aware of recepientlist, dynamic router.
Suppose I have a list of endpoint url's, how can i build route by iterating
the list ??
List<ObjectWithTypeAndURl> listOfEndpoints=............
In Route builder configure method can i define a single route in multiple
steps???
for eg..
from(listOfEndpoints.get(0));
iterating
to(listOfEndpoints.get(..));
something like this??
-----
Regards
kiran Reddy
--
View this message in context: http://camel.465427.n5.nabble.com/building-route-in-java-dsl-tp5727483.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: building route in java dsl
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Feb 13, 2013 at 10:12 AM, kiranreddykasa <ki...@fss.co.in> wrote:
>
> Can anyone tell me how to build camel route dynamically in dsl.
>
> I am aware of recepientlist, dynamic router.
>
> Suppose I have a list of endpoint url's, how can i build route by iterating
> the list ??
>
> List<ObjectWithTypeAndURl> listOfEndpoints=............
>
> In Route builder configure method can i define a single route in multiple
> steps???
>
> for eg..
>
> from(listOfEndpoints.get(0));
> iterating
> to(listOfEndpoints.get(..));
>
>
> something like this??
>
Yeah remember its just Java code. So you can use for loops / if ..
else constructs etc.
But you would need to use variables to break up the DSL and add to it later.
See this unit test for an example
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/management/BigRouteTest.java
>
>
>
>
> -----
> Regards
>
> kiran Reddy
> --
> View this message in context: http://camel.465427.n5.nabble.com/building-route-in-java-dsl-tp5727483.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
AW: building route in java dsl
Posted by "Jan Matèrne (jhm)" <ap...@materne.de>.
Even a JavaDSL is Java code, so you could store intermediate steps while
creating the route - just "extract local variable".
So you could use Java control commands:
public class ProgrammaticalRouteTest extends CamelTestSupport {
@Test
public void sendToMultipleEndpoints() throws InterruptedException {
getMockEndpoint("mock:end1").expectedMessageCount(1);
getMockEndpoint("mock:end2").expectedMessageCount(1);
getMockEndpoint("mock:end3").expectedMessageCount(1);
template.sendBody("direct:in", "test");
assertMockEndpointsSatisfied();
}
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
List<String> endpointUris = Arrays.asList(
"mock:end1",
"mock:end2",
"mock:end3"
);
RouteDefinition route = from("direct:in");
for(String epUri : endpointUris) {
route.to(epUri);
}
}
};
}
}
Jan
-----Ursprüngliche Nachricht-----
Von: kiranreddykasa [mailto:kirankumarrk@fss.co.in]
Gesendet: Mittwoch, 13. Februar 2013 10:13
An: users@camel.apache.org
Betreff: building route in java dsl
Can anyone tell me how to build camel route dynamically in dsl.
I am aware of recepientlist, dynamic router.
Suppose I have a list of endpoint url's, how can i build route by iterating
the list ??
List<ObjectWithTypeAndURl> listOfEndpoints=............
In Route builder configure method can i define a single route in multiple
steps???
for eg..
from(listOfEndpoints.get(0));
iterating
to(listOfEndpoints.get(..));
something like this??
-----
Regards
kiran Reddy
--
View this message in context:
http://camel.465427.n5.nabble.com/building-route-in-java-dsl-tp5727483.html
Sent from the Camel - Users mailing list archive at Nabble.com.