2 Replies Latest reply on May 23, 2011 10:22 AM by Gabriele Contini

    Cluster SLSB load balancing.

    Gabriele Contini Newbie

      Hi!

      I'm using jboss 6 and I'm trying to load balance remote ejb calls in a cluster. I want that some of the remote calls are routed on nodes other than the current one. (I have a TimerService deployed as a singleton and i want to load balance the batch load).

      I've run into a problem that's documented here:

      http://community.jboss.org/wiki/ClusteringFAQ "Why are calls between clustered session beans not load balanced even though load balancing policy is Round Robin?".

      I don't want to undeploy some of the ejb from one of the containers, so i wrote my own interceptor as described in the wiki.

       

      {code}

      package acme;

       

       

      import org.jboss.invocation.Invocation;

      import org.jboss.invocation.InvokerInterceptor;

       

       

      public class MyInvokerInterceptor extends InvokerInterceptor {

       

       

                @Override

                public boolean hasLocalTarget(final Invocation invocation) {

                          return false;

                }

      }

      {code}

       

      Then i tried to configure it in standardjboss.xml. I modified the "clustered-stateless-unified-invoker" replacing:

      {noformat}

      <interceptor call-by-value="false">org.jboss.invocation.InvokerInterceptor</interceptor>

      {noformat}

      with:

      {noformat}

      <interceptor call-by-value="false">acme.MyInvokerInterceptor</interceptor>

      {noformat}

       

      and i've configured the correct "invoker-proxy-binding-name" in jboss.xml into my application jar, but yet remote calls always choose the same cluster node where they are generated.

       

       

      I tried a completely different way modifying ejb3-interceptors-aop.xml, commenting out:

      {noformat}
      

      <interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>

      {noformat}

      at this point remote calls are load balanced and everything seem to work fine (in my sample i use no persistence yet) but i get the following exception:

      {noformat}

      12:48:31,049 ERROR [STDERR] java.lang.RuntimeException: cannot import a transaction context when a transaction is already associated with the thread

      12:48:31,050 ERROR [STDERR]           at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:62)

      12:48:31,050 ERROR [STDERR]           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

      {noformat}

      How can i avoid this exception?

      Gabriele

        • 1. Cluster SLSB load balancing.
          Wolf-Dieter Fink Master

          AFAIK, you can not have transactions across different server (my experience is from EJB2).

          If you start local without a transaction I suppose it will work.

           

          The default behaviour is to stay local because of a better performance.

          • 2. Cluster SLSB load balancing.
            Gabriele Contini Newbie

            Thank you, you're right starting without a transaction works fine.

            To summarize all my previous post i can say:

            In order to get the SLSB remote calls load balanced in a cluster you must modify "ejb3-interceptors-aop.xml" under the section "ClusteredStatelessSessionClientInterceptors" commenting out:

            <interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>

            And you must call the remote bean without an active transaction in context.

             

            The invocation stack can be choosen on a "per session bean"  in jboss.xml:

             

            <session>

                                          <ejb-name>RemoteImpl2</ejb-name>

                                          <remote-binding>

                                                    <interceptor-stack>ClusteredStatelessSessionClientInterceptors</interceptor-stack>

                                          </remote-binding>

                                          <clustered>true</clustered>

            </session>

             

            This strategy requires a modification to a global configuration file. Is there a way to avoid this and do the full configuration inside my ejb jar?

            Somebody is trying to do this without success http://community.jboss.org/message/536906