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 >