[jboss-user] [Clustering/JBoss] - load-balance-policy tag in jboss.xml not working
pmadzik
do-not-reply at jboss.com
Fri Oct 6 07:02:26 EDT 2006
Hello!
I try to obtain clustering for SLSB using jboss.xml description:
| HelloBean.java:
| import javax.ejb.Stateless;
|
| import java.net.InetAddress;
| import java.net.UnknownHostException;
|
| import org.jboss.annotation.ejb.Clustered;
|
| @Stateless//@Clustered(loadBalancePolicy=org.jboss.ha.framework.interfaces.RoundRobin.class)public class HelloBean implements HelloRemote {
| public String sayHelloFrom() throws UnknownHostException {
| String host = InetAddress.getLocalHost().getHostAddress();
|
| return "Hello from " + host + "!";
| }
| }
|
| jboss.xml:
| <?xml version="1.0"?>
| <jboss
| xmlns="http://java.sun.com/xml/ns/javaee"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
| http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
| version="3.0">
| <enterprise-beans>
| <session>
| <ejb-name>HelloBean</ejb-name>
| <clustered>true</clustered>
| <cluster-config>
| <partition-name>${jboss.partition.name:DefaultPartition}</partition-name> <load-balance-policy>org.jboss.ha.framework.interfaces.RoundRobin</load-balance-policy> </cluster-config>
| </session>
| </enterprise-beans>
| </jboss>
|
| Client.java:
| import javax.naming.InitialContext;
| import javax.naming.Context;
| import javax.naming.NamingException;
|
| import java.net.UnknownHostException;
|
|
| public class Client
| {
| public static void main(String[] args)
| {
| try {
| Context jndiContext = getInitialContext();
| Object ref = jndiContext.lookup("HelloBean/remote");
| HelloRemote hello = (HelloRemote) ref;
|
| for (int i = 0; i < 10; i++) {
| System.out.println(hello.sayHelloFrom());
| }
| }
| catch (NamingException ne) {
| ne.printStackTrace();
| }
| catch (UnknownHostException he) {
| he.printStackTrace();
| }
| }
|
| public static Context getInitialContext() throws NamingException
| {
| return new InitialContext();
| }
| }
|
I setup cluster with to nodes (10.1.2.71, 10.1.1.192).
After client start i always get:
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
| Hello from 10.1.1.192!
|
or
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
| Hello from 10.1.2.71!
|
Seems that load-balance-policy tag is not working because removing comment with @Clustered annotation in HelloBean.java results:
| Hello from 10.1.1.192!
| Hello from 10.1.2.71!
| Hello from 10.1.1.192!
| Hello from 10.1.2.71!
| Hello from 10.1.1.192!
| Hello from 10.1.2.71!
| Hello from 10.1.1.192!
| Hello from 10.1.2.71!
| Hello from 10.1.1.192!
| Hello from 10.1.2.71!
|
Is it bug in jboss or in my configuration?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976539#3976539
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976539
More information about the jboss-user
mailing list