4 Replies Latest reply on Jun 1, 2012 4:40 AM by jrawlings1980

    Fabric load balancing - what should the serviceClass be set to?

    jrawlings1980

      Hi, I'm following the Fabric load balancing client configuration.  I cannot deploy the load balance client because it cannot resolve the serviceClass.

       

       

         <!-- Create a client proxy, with load balancing enabled -->
          <jaxws:client id="ClientProxyBeanID"
              address="http://dummyaddress"
              serviceClass="SEI">
              <jaxws:features>
                  <ref bean="fabricLoadBalancerFeature"></ref>
              </jaxws:features>
          </jaxws:client>
      

       

      I have two child remote containers on different machines clustering my inbox service.  The load balancing client is deployed in a separate container again so doesn't know about the inbox service.

       

      What should serviceClass be set to?  My CXF implementation on the WS server side is com.mycompany.InboxImpl.  I would have assumed serviceClass="com.mycompany.Inbox" but I get a class not found exception.

       

      Edited by: rawlingsj on May 28, 2012 10:48 PM

       

      I managed to get a bit further but I'm not happy it's correct.  I've had to deploy my inbox api along with the load balancing client so that the serviceClass can be resolved.  Is this correct?

       

      Also please can someone look over my configuration below.  I'm not sure I'm linking my client proxy to the load balancer correctly, I don't think the soap message is passed.

       

          <!-- Create a client proxy, with load balancing enabled -->
          <jaxws:client id="ClientProxyBeanID"
              address="http://dummyaddress"
              serviceClass="com.mycompany.Inbox">
              <jaxws:features>
                  <ref component-id="fabricLoadBalancerFeature"></ref>
              </jaxws:features>
          </jaxws:client>
      
          <reference id="org.linkedin.zookeeper.client.IZKClient"
                     interface="org.linkedin.zookeeper.client.IZKClient"></reference>
      
          <!-- Create the Fabric load balancer feature -->
          <bean id="fabricLoadBalancerFeature"
                class="org.fusesource.fabric.cxf.FabricLoadBalancerFeature">
              <property name="zkClient" ref="org.linkedin.zookeeper.client.IZKClient"></property>
              <property name="fabricPath" value="inbox/lb"></property>
          </bean>
      
           <camelContext xmlns="http://camel.apache.org/schema/blueprint">
               <route>
                   <description>Inbox load balancer</description>
                   <from uri="jetty:http://0.0.0.0:8185/inbox-lb" id="inbox-lb">
                       <description></description>
                   </from>
                   <log message="** Hit the load balancer **"></log>
                   
                   <bean ref="ClientProxyBeanID"></bean>
               </route>
           </camelContext>
      

      Any advice would be great.

        • 1. Re: Fabric load balancing - what should the serviceClass be set to?
          njiang

          Hi,

           

          From you description, it looks like you just want to proxy the request by using camel route to the back end which is powered by Fabric.

           

          Basically, you can do it directly in Camel without using Fabric like this

             from("jetty://xxx").loadBalance().Failover().to("http://IP1", "http://IP2);
          

           

          CXF-fabric doesn't use the camel route underlay, it's just leverage the CXF loadbalance feature and locator.

           

          Willem

          • 2. Re: Fabric load balancing - what should the serviceClass be set to?
            jrawlings1980

            Ok thanks.  This is certainly an option as I don't seem to be getting any where with the Fabric load balancer.  I must admit though I would prefer to use fabric as it means I can dynamically add new containers which would register with the locator.  I also read somewhere that it can favor containers that perform faster.

             

            With the fabric configuration above I get the following error on the client.  I'm sure I have the serviceClass wrong as I shouldn't have to deploy my WS server bundle along with the load balance client just so it can resolve com.mycompany.inbox (LB client and WS server are on different VMs).  This is also where the exception below comes from.

             

            2012-05-29 10:50:46,817 | ERROR | qtp14548925-855  | DefaultErrorHandler              | 144 - org.apache.camel.camel-core - 2.9.0.fuse-7-061 | Failed delivery for (MessageId: ID-fi-VirtualBox-50473-1338224387142-11-6 on ExchangeId: ID-fi-VirtualBox-50473-1338224387142-11-5). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous method invocations possible: [public final java.lang.Long[] $Proxy87.getInboxes(java.lang.String) throws com.mycompany.inbox.exception.InvalidValueExcepion, public final java.lang.Long[] $Proxy87.getInboxes(java.lang.String) throws com.mycompany.inbox.exception.InvalidValueExcepion]. Exchange[Message: [Body is instance of org.apache.camel.StreamCache]]
            org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous method invocations possible: [public final java.lang.Long[] $Proxy87.getInboxes(java.lang.String) throws com.mycompany.inbox.exception.InvalidValueExcepion, public final java.lang.Long[] $Proxy87.getInboxes(java.lang.String) throws com.mycompany.inbox.exception.InvalidValueExcepion]. Exchange[Message: [Body is instance of org.apache.camel.StreamCache]]
                    at org.apache.camel.component.bean.BeanInfo.chooseBestPossibleMethodInfo(BeanInfo.java:588)[144:org.apache.camel.camel-core:2.9.0.fuse-7-061]
                    at org.apache.camel.component.bean.BeanInfo.chooseMethodWithMatchingBody(BeanInfo.java:545)[144:org.apache.camel.camel-core:2.9.0.fuse-7-061]
                    at org.apache.camel.component.bean.BeanInfo.chooseMethod(BeanInfo.java:497)[144:org.apache.camel.camel-core:2.9.0.fuse-7-061]
                    at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:226)[144:org.apache.camel.camel-core:2.9.0.fuse-7-061]

             

            • 3. Re: Fabric load balancing - what should the serviceClass be set to?
              njiang

              Hi,

              You are specifying a wrong CXF endpoint in the Camel route.

              Please check out the camel-cxf document[1] for more information.

              BTW, you can set the feature as the jaxws endpoint does.

               

              http://camel.apache.org/cxf.html#CXF-ConfiguretheCXFendpointswithSpring

               

              Willem

              • 4. Re: Fabric load balancing - what should the serviceClass be set to?
                jrawlings1980

                Thank you!