5 Replies Latest reply on Sep 10, 2007 5:17 AM by ricott

    EJB 3.0 Session Bean (Stateless) Cluster

    chapata gunner Newbie

      Hi,

      I have two machines which are running JBoss 4.2.0GA 'all' domain and are automatically clustered under the 'Default Partition'. Now I want to achieve the following design -

      There is a Servlet which should send requests to a stateless session bean, which is deployed to both servers (via farm), in a round robin fashion i.e. if the bean in Server A gets the request first time...the bean in Server B should get the request next time.

      Can anyone suggest how to do this in a scaleable way?
      Any help will be greatly appreciated.

      Regards.


        • 1. Re: EJB 3.0 Session Bean (Stateless) Cluster
          chapata gunner Newbie

          Did a little more research...

          http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4059988#4059988


          If i put the code that I used to put in a Servlet inside a normal Java file and execute it ... Everything works properly. So it seems that in order for LoadBalancing to work properly we need to execute the calls from a separate JVM. Is that correct?

          Can anyone please confirm it?

          Also is there any way to move past this restriction?


          • 2. Re: EJB 3.0 Session Bean (Stateless) Cluster
            chapata gunner Newbie

            OK! Finally found a solution to my problem :)

            JBoss 'all' domain comes with certain AOP interceptors for EJB3. Of these the IsLocalInterceptor and ClusteredIsLocalInterceptor were creating all this fuss. I just disabled them and everything works fine.

            • 3. Re: EJB 3.0 Session Bean (Stateless) Cluster
              Brian Stansberry Master

              You'vre done well on your hunt. :-)

              Be aware, though, that you might have problems if you have a transaction running and you make an EJB call that ends up going to the in-VM bean. The TxPropagationInterceptor will not handle this well if the (Clustered)IsLocalInterceptor is bypassed. See http://jira.jboss.com/jira/browse/EJBTHREE-1005.

              This will only be a problem for you if your servlet initiates transactions or your beans make calls from one to another within a tx.

              • 4. Re: EJB 3.0 Session Bean (Stateless) Cluster
                ricott Newbie

                I'm trying to do the exact same thing and I also noticed that the round robin works if the client code is executed from another jvm. I see your solution is to disable IsLocalInterceptor and ClusteredIsLocalInterceptor in the ejb3-interceptors-aop.xml file. I see in the DTD that the interceptor scope can be PER_VM|PER_CLASS|PER_INSTANCE|PER_JOINPOINT|PER_CLASS_JOINPOINT and the default is PER_VM. What value should I change it to or what do you mean by disabling IsLocalInterceptor and ClusteredIsLocalInterceptor?

                • 5. Re: EJB 3.0 Session Bean (Stateless) Cluster
                  ricott Newbie

                  I must say that I'm a bit puzzled that this is something that you must configure in an (obscure) config file in order to get it to work. And perhaps even more that you cannot find anything about it in the documentation.

                  Is it an uncommon scenario that you want to have a process that runs on one node in a cluster and then spreads the load on all nodes via a clustered slsb that typically uses round robin? At least I didn?t think so before I tried it.

                  Anyways, I found the place in the ejb3-interceptors-aop.xml file (I think) and got it working

                  <stack name="StatelessSessionClientInterceptors">
                   <!--<interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>-->
                   <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
                   <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
                   <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
                  </stack>
                  

                  And
                  <stack name="ClusteredStatelessSessionClientInterceptors">
                   <!--<interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>-->
                   <interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
                   <interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
                   <interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
                   <interceptor-ref name="org.jboss.aspects.remoting.InvokeRemoteInterceptor"/>
                  </stack>