You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by serega <se...@sybase.com> on 2010/12/22 22:25:42 UTC
LoadBalansing configuration
Hi.
I can easily create a route using Java DSL of the form
from("foo").loadBalance().to("bar").("bla"),
which is perfect for static routes.
How can I do the same but without DSL. Something like
CamelContext context = new DefaultCamelContext();.
LoadBalancer balancer = new RoundRobinLoadBalancer();
balancer.addEndpoint("bar");
balancer.addEndpoint("bla");
....
balancer.removeEndpoint("bar")
I need to be able to add/remove endpoints to/from load balancers at runtime.
Is it possible with Camel?
Sergey.
--
View this message in context: http://camel.465427.n5.nabble.com/LoadBalansing-configuration-tp3315711p3315711.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: LoadBalansing configuration
Posted by Willem Jiang <wi...@gmail.com>.
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
Re: LoadBalansing configuration
Posted by serega <se...@sybase.com>.
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".
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 */ }).
Thanks,
Sergey.
--
View this message in context: http://camel.465427.n5.nabble.com/LoadBalansing-configuration-tp3315711p3316580.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: LoadBalansing configuration
Posted by Willem Jiang <wi...@gmail.com>.
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.
Please create a JIRA if you cannot work around it with my suggestion.
Willem
On 12/23/10 5:25 AM, serega wrote:
>
> Hi.
> I can easily create a route using Java DSL of the form
> from("foo").loadBalance().to("bar").("bla"),
> which is perfect for static routes.
> How can I do the same but without DSL. Something like
> CamelContext context = new DefaultCamelContext();.
> LoadBalancer balancer = new RoundRobinLoadBalancer();
> balancer.addEndpoint("bar");
> balancer.addEndpoint("bla");
> ....
>
> balancer.removeEndpoint("bar")
>
> I need to be able to add/remove endpoints to/from load balancers at runtime.
> Is it possible with Camel?
>
> Sergey.
>
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang