camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: LoadBalansing configuration
Date Fri, 24 Dec 2010 03:53:02 GMT
On 12/23/10 11:17 PM, serega wrote:
>
>
> Willem.Jiang wrote:
>>
>> Hi,
>> I don't think Camel support to add and remove the endpoints of the
>> LoadBalancer as you want in the runtime.
>> But the now camel route can be start and stop in the runtime. maybe you
>> can consider to stop the route, change the route and start it again.
>>
>
> Can you elaborate on "stop the route, change the route and start it again".
CamelContext provides API to let you stop the route and remove it.
You just need to name your route with a meaningful ID.

Then you can add a new route which is set with different load balance 
endpoints.

>
> And related question.
> The following code
> /**************************************/
> RouteDefinition route = new RouteDefinition();
> route.from("sergey:in")
>                  .process(new Processor() {
>                      public void process(Exchange exchange) throws Exception
> {
>                          System.out.println("Received " + exchange.getIn());
>                      }
>                  })
>                  .loadBalance().roundRobin()
>                  .to("jms1:queue:testqueue")
>                  .to("jms1:queue:testqueue2")
>                  .to("jms2:queue:testqueue");
>
> context.addRouteDefinition(route);
> context.start();
> /***********************************/
> gives me exception
> Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> Failed to create route route1 at:>>>  LoadBalanceType[ref:null, []]<<<
 in
> route: Route[[From[sergey:in]] ->  [process[com.sybase365.CamelJmsTe...
> because of ref or loadBalancer must be specified
>
> But it works if I do the same using  context.addRoutes(new RouteBuilder() {
> /* same configuration */ }).
The RouteBuilder is helper the user to use the Java DSL more easily, if 
you dig the code for a while you will find it does lots of things 
undergrad before create a RouteDefinition :)

>
> Thanks,
>
> Sergey.
>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Mime
View raw message