[jboss-user] [EJB 3.0] - @Clustered! How to check if its working?

chapata_gunner do-not-reply at jboss.com
Tue Jul 3 10:20:22 EDT 2007


I have a bean which has been defined as follows.

  | @Stateless
  | @Clustered
  | public class StatelessCalculatorBean implements Calculator {
  |     
  |     public double calculate(int start, int end, double growthrate, double saving) {
  |         double tmp = Math.pow(1. + growthrate / 12., 12. * (end - start) + 1);
  |         return saving * 12. * (tmp - 1) / growthrate;
  |     }
  |     
  | }
  | 

This is the bean interface.

  | @Remote
  | public interface Calculator {
  |     
  |     public double calculate(int start, int end, double growthrate, double saving);
  |     
  | }
  | 

This EJB is deployed on two JBoss 4.2.0GA servers (running on different machines with 'all' domain).

Now I lookup this EJB in a Servlet and call the calculate method on it 4 times.

  |         Properties p = new Properties();
  |         p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
  |         p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
  |         p.put(Context.PROVIDER_URL, "actual ip_01:1100,actual ip_02:1100");
  |         InitialContext ctx = new InitialContext(p);
  |         cal = (Calculator) ctx.lookup("StatelessCalculatorBean/remote");
  |         cal.calculate(25, 65, 0.08, 300.0);
  |         cal.calculate(35, 75, 0.08, 300.0);
  |         cal.calculate(45, 85, 0.08, 300.0);
  |         cal.calculate(55, 95, 0.08, 300.0);
  | 

Now I want 2 of these calls to hit ip_01 and 2 calls to hit ip_02 in a RoundRobin way...which is the default for @Clustered in SLSB (as per the wiki).

Can anyone tell me what I am doing wrong here? For some reason only the EJB from ip_01 is being called for all 4 instances. 
The Servlet is present only on the ip_01 machine.

Any help will be greatly appreciated!


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

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



More information about the jboss-user mailing list