You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Sebastian Bösl <sb...@gmx.de> on 2013/09/02 13:52:35 UTC
Problem with FailOverLoadBalancer
Hi,
I've a problem calling a REST based service with dynamic uris in combination with a failover load balancer.
Below is how I do it at the moment but I'm open to better solutions.
It would also be great if there is a way that I can inject a dynamic number of endpoints, so I could inject a thrid cluster node without changing the code.
I've designed the route as
from("direct:a")
.loadBalance()
.failover(-1, false, false)
.recipientList(simple(endpoints[0]))
.recipientList(simple(endpoints[1]))
.end()
Which leads to this exception:
Caused by: java.lang.ClassCastException: org.apache.camel.model.LoadBalanceDefinition cannot be cast to org.apache.camel.model.ExpressionNode
at com.sbo.MyRouteBuilder.configure(QuovaRouteBuilder.java:52)
at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:322)
at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:276)
at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:262)
at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:650)
at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.installRoutes(AbstractCamelContextFactoryBean.java:658)
at org.apache.camel.core.xml.AbstractCamelContextFactoryBean.afterPropertiesSet(AbstractCamelContextFactoryBean.java:282)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
... 50 more
If I change the route to
from("direct:a")
.loadBalance()
.failover(-1, false, false)
.process(new RecipientList(getContext(), simple(endpoints[0])))
.process(new RecipientList(getContext(), simple(endpoints[1])))
.end()
It works as expected, so I guess there is an internal bug somewhere.
Thanks,
Sebastian
Re: Problem with FailOverLoadBalancer
Posted by Willem Jiang <wi...@gmail.com>.
Event you are using the RecipientList, you just setup the fail over
endpoint at the design time not the run time.
Fuse Fabric[1] can provide the dynamic fail over by leveraging the Zoo
Keeper to keep tracking the endpoints.
[1]http://fuse.fusesource.org/fabric/docs/overview.html#Camel_Fabric
Willem Jiang
Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/)
(English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
On Mon, Sep 2, 2013 at 7:52 PM, "Sebastian Bösl" <sb...@gmx.de> wrote:
> Hi,
>
> I've a problem calling a REST based service with dynamic uris in
> combination with a failover load balancer.
> Below is how I do it at the moment but I'm open to better solutions.
> It would also be great if there is a way that I can inject a dynamic
> number of endpoints, so I could inject a thrid cluster node without
> changing the code.
>
> I've designed the route as
> from("direct:a")
> .loadBalance()
> .failover(-1, false, false)
> .recipientList(simple(endpoints[0]))
> .recipientList(simple(endpoints[1]))
> .end()
>
> Which leads to this exception:
> Caused by: java.lang.ClassCastException:
> org.apache.camel.model.LoadBalanceDefinition cannot be cast to
> org.apache.camel.model.ExpressionNode
> at com.sbo.MyRouteBuilder.configure(QuovaRouteBuilder.java:52)
> at
> org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:322)
> at
> org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:276)
> at
> org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:262)
> at
> org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:650)
> at
> org.apache.camel.core.xml.AbstractCamelContextFactoryBean.installRoutes(AbstractCamelContextFactoryBean.java:658)
> at
> org.apache.camel.core.xml.AbstractCamelContextFactoryBean.afterPropertiesSet(AbstractCamelContextFactoryBean.java:282)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
> ... 50 more
>
> If I change the route to
> from("direct:a")
> .loadBalance()
> .failover(-1, false, false)
> .process(new RecipientList(getContext(),
> simple(endpoints[0])))
> .process(new RecipientList(getContext(),
> simple(endpoints[1])))
> .end()
> It works as expected, so I guess there is an internal bug somewhere.
>
> Thanks,
>
> Sebastian
>
Re: Problem with FailOverLoadBalancer
Posted by sbo13 <sb...@gmx.de>.
Thank's Claus, I must admitt I hadn't thought about that.
--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-FailOverLoadBalancer-tp5738515p5738728.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Problem with FailOverLoadBalancer
Posted by Claus Ibsen <cl...@gmail.com>.
There is low-level API on the FailOverProcessor which can add/remove at runtime.
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/LoadBalancerSupport.html#addProcessor(org.apache.camel.Processor)
Though there is no nice high level API to do that. There is a JIRA
ticket about adding JMX APIs for adding/removing endpoints uris.
But the FailOverLB was designed to not be dynamic from the start. But
maybe in a future Camel release it would be easier to add/remove uris
on-the-fly.
You can always implement your own processor to do this today. Or
extend the existing ones and build added logic.
On Wed, Sep 4, 2013 at 5:10 PM, sbo13 <sb...@gmx.de> wrote:
> Has nobody a solution for adding a variable number of endpoints with dynamic
> uris?
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-FailOverLoadBalancer-tp5738515p5738689.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: Problem with FailOverLoadBalancer
Posted by sbo13 <sb...@gmx.de>.
Has nobody a solution for adding a variable number of endpoints with dynamic
uris?
--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-FailOverLoadBalancer-tp5738515p5738689.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Problem with FailOverLoadBalancer
Posted by sbo13 <sb...@gmx.de>.
Has nobody a solution for adding a variable number of endpoints with dynamic
uris?
--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-FailOverLoadBalancer-tp5738515p5738692.html
Sent from the Camel - Users mailing list archive at Nabble.com.