[jboss-user] [Clustering/JBoss] - Load-balancing is not happening in cluster

azheludkov do-not-reply at jboss.com
Mon Jan 21 13:32:16 EST 2008


Does anybody know why stateless EJB is executed always on the node where client resides and is never load balanced?

I have successfully configured a two-node JBoss cluster, and deployed an EJB module to the cluster.  When running the test client to invoke the EJB, all requests are always serviced by node 1 (where ejb client resides), never by node 2.

Here is another interesting detail. When client runs from outside of JBoss  as stand-alone application and submits requests to JBoss cluster, the cluster routes requests to different nodes. I mean load-balancing works.   
Another factor in my application is, client invokes the ejb from inside JBoss.
On the JBoss forum http://www.jboss.com/index.html?module=bb&op=viewtopic&t=112500
 I found something similar to my problem, but I gess it only works for ejb 3.x, not ejb 2.x 

Here are configuration details:
- JBoss 4.2.2-GA;
- EJB client runs inside of JBoss container;
- SLSB 2;
- JNDI properties:
java.naming.provider.url = jnp://localhost:1100
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
jnp.partitionName=DefaultPartition

- jboss.xml:

    <enterprise-beans>
        
            <ejb-name>SubmitterBean</ejb-name>
            <jndi-name>Submitter</jndi-name>
	    true
		<cluster-config>          
                    <partition-name>DefaultPartition</partition-name>          
	            <home-load-balance-policy>                 
        	        org.jboss.ha.framework.interfaces.RoundRobin          
                    </home-load-balance-policy>          
	            <bean-load-balance-policy>  
        	        org.jboss.ha.framework.interfaces.RoundRobin
                    </bean-load-balance-policy>
            </cluster-config>
        
    </enterprise-beans>

My client creates home stub only once and caches it. For every ejb invocation a new remote interface stub is created.
In client class constructor I create home stab only once and cache it as a member variable:

Properties props = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory")
. . . 
See all properties above.
. . .
Context ctx = new InitialContext(jndiProperties);
Object obj = ctx.lookup(lookupName);
m_home = (SubmitterHome) javax.rmi.PortableRemoteObject.narrow(obj, SubmitterHome.class);

But for every EJB invocation I create new remote interface stub, like here:
   Submitter execute = null;
   try {
       execute = (Submitter) m_home.create();
     execute.submitJob(m_jt);
   } catch (Exception ex) {
        	ex.printStackTrace();
   }
}

Any help would be much appreciated.
Thanks.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4121920#4121920

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4121920



More information about the jboss-user mailing list