4 Replies Latest reply on Sep 2, 2010 10:09 AM by nsemchenkov

    Load balance policy for multiple EJBs in single place

    nsemchenkov

      Hello!

       

      We have three-tiered application (Eclipse RCP -> cluster of JBoss AS instances -> Postgres database). We've implemented tricky custom EJB load balance policy, based on memory consumption, CPU load etc of each server node in cluster.

      We have hundreds of different EJBs in our application, so necessity to mark all of them with @Clustered annotation is not a good idea. We've used ejb3-interceptors-aop.xml file to specify our custom load balance policy in single place:

       

      <annotation expr="class(@javax.ejb.Remote) AND !class(@org.jboss.annotation.ejb.Clustered)">
           @org.jboss.annotation.ejb.Clustered(partition="${jboss.partition.name}",loadBalancePolicy=net.uk.topdog.td2.ha.StatefulAvailabilityLoadBalancePolicy.class)
      </annotation>

       

      But after updating out server from JBoss 4.2 to JBoss 5.1 this solution stop working

       

      So, can someone advice the proper way of specifying load balance policy for multiple EJBs in single place under JBoss 5?

        • 1. Re: Load balance policy for multiple EJBs in single place
          jaikiran

          @org.jboss.annotation.ejb.Clustered

           

          In AS-5, the JBoss EJB3 specific annotations have moved to org.jboss.ejb3.annotation package. For this specific annotation, it would now be @org.jboss.ejb3.annotation.Clustered. So you should change those references in your *-aop.xml (and any code) to use these new annotations.

          • 2. Re: Load balance policy for multiple EJBs in single place
            nsemchenkov

            Yes, we've tried to make corresponding changes to ejb3-interceptors-aop.xml:

             

            <annotation expr="class(@javax.ejb.Remote) AND !class(@org.jboss.ejb3.annotation.Clustered)">
                 @org.jboss.ejb3.annotation.Clustered(loadBalancePolicy="net.uk.topdog.td2.ha.StatelessAvailabilityLoadBalancePolicy")
            </annotation>

             

            But this configuration also doesn't work - the system uses default RoundRobin load balance policy instead.

            • 3. Re: Load balance policy for multiple EJBs in single place
              jaikiran

              Post the relevant bean code and the entire ejb3-interceptors-aop.xml that you are using (including the modifications).

               

              P.S: While posting, please use the forum editor's syntax highlighting options to format the code and the xml.

              • 4. Re: Load balance policy for multiple EJBs in single place
                nsemchenkov

                Example of EJB:

                 

                @Stateless(name = "LoginModuleSessionBean")
                @Remote(ILoginModule.class)
                @RemoteBinding(jndiBinding = "LoginModuleSessionBean/remote")
                @TransactionManagement(TransactionManagementType.BEAN)
                public class LoginModuleSessionBean implements ILoginModule {
                
                     public LoginResponse login(LoginRequest request) {
                          // Some code here    
                     }
                }
                

                 

                Stateless bean domain in ejb-interceptors-aop.xml file:

                 

                   <domain name="Stateless Bean" extends="Intercepted Bean" inheritBindings="true">
                        <bind pointcut="execution(public * *->*(..))">
                            <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor" />
                            <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory" />
                        </bind>
                        <bind pointcut="execution(public * @org.jboss.ejb3.annotation.SecurityDomain->*(..))">
                            <interceptor-ref name="Basic Authorization" />
                        </bind>
                        <bind pointcut="execution(public * *->*(..))">
                            <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory" />
                        </bind>
                        <bind pointcut="execution(public * @org.jboss.ejb3.annotation.Clustered->*(..))">
                            <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory" />
                        </bind>
                        <bind pointcut="execution(public * *->*(..))">
                            <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor" />
                            <interceptor-ref name="org.jboss.ejb3.tx.CMTTxInterceptorFactory" />
                            <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor" />
                            <interceptor-ref name="InvocationStatisticsInterceptor" />
                            <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory" />
                            <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor" />
                            <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" />
                            <!-- interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/ -->
                            <stack-ref name="EJBInterceptors" />
                        </bind>
                        <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Pool)">
                            @org.jboss.ejb3.annotation.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
                        </annotation>
                        <annotation expr="class(@javax.ejb.Remote) AND !class(@org.jboss.ejb3.annotation.Clustered)">
                            @org.jboss.ejb3.annotation.Clustered(loadBalancePolicy="net.uk.topdog.td2.ha.StatelessAvailabilityLoadBalancePolicy")
                        </annotation>
                    </domain>