camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: how to add some routes to CamelContext by hand?
Date Fri, 29 Jul 2011 05:59:48 GMT
On Fri, Jul 29, 2011 at 6:07 AM, xiangqiuzhao <xiangqiuzhao@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/

Mime
View raw message