You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by xiangqiuzhao <xi...@gmail.com> on 2011/07/29 06:07:21 UTC

how to add some routes to CamelContext by hand?

i have get some endpoint uri strings, 

and some route be defined as 

from(endpoint1).to(direct:name)
from(endpoint2).to(direct:name)
...

i have new CamelContext(), and want to add these route to it then start.
how to add dynamic use api, not use like :

context.addRoutes(new RouteBuilder() {
            public void configure() throws Exception {
                from("endpoint1")
                .to("direct:name");
            }
        });

because i don't know how many route i should add, i must parse my configure
file to add dynamic 

--
View this message in context: http://camel.465427.n5.nabble.com/how-to-add-some-routes-to-CamelContext-by-hand-tp4644999p4644999.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: how to add some routes to CamelContext by hand?

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jul 29, 2011 at 6:07 AM, xiangqiuzhao <xi...@gmail.com> wrote:
> i have get some endpoint uri strings,
>
> and some route be defined as
>
> from(endpoint1).to(direct:name)
> from(endpoint2).to(direct:name)
> ...
>
> i have new CamelContext(), and want to add these route to it then start.
> how to add dynamic use api, not use like :
>

Its just java code so you can use for loops etc. to add X number of routes

 context.addRoutes(new RouteBuilder() {
            public void configure() throws Exception {

for (int i = 0; i < 10; i++) {
                from("endpoint1" + i)
                .to("direct:name" + i);
            }

        });


If you do not want to use the RouteBuilder, then you can manually
build routes using the classes in the org.apache.camel.model package.


> because i don't know how many route i should add, i must parse my configure
> file to add dynamic
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/how-to-add-some-routes-to-CamelContext-by-hand-tp4644999p4644999.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: how to add some routes to CamelContext by hand?

Posted by xiangqiuzhao <xi...@gmail.com>.
i look RouteDefinition class in camel-core javadoc from website 
 public RouteDefinition(Endpoint endpoint)

what the input endpoint mean?

but i can't find the souce from 2.7.2 version

--
View this message in context: http://camel.465427.n5.nabble.com/how-to-add-some-routes-to-CamelContext-by-hand-tp4644999p4645019.html
Sent from the Camel - Users mailing list archive at Nabble.com.