I created a partition with a single bean in it. I then cloned the
partition. I run one osagent. Osfind tells me that it has both EJBs are
registered with the agent. I created a basic EJB client (from the wizard)
and put this in the main method.
for(int i=0;i<10;i++){
//get naming context
Context context = new InitialContext();
//look up jndi name
Object ref = context.lookup("Enterprise1");
System.out.println(ref.toString());
//look up jndi name and cast to Home interface
Enterprise1Home enterprise1Home =
(Enterprise1Home)PortableRemoteObject.narrow(ref, Enterprise1Home.class);
System.out.println(enterprise1Home.create().helloWorld(i));
}
}
Each time I call context.lookup, shouldn't I get a new home interface?
Shouldn't it load balance between them? This is what happens instead: The
first time I run, I get serviced ten times by one partition. I stop the
client. I run it again, I get serviced ten times by the other partition. I
stop the client. I run it a third time, get serviced ten times by the first
partition. I have also tried changing the code like this:
//get naming context
Context context = null;
Object eh1 = null;
Object eh2 = null;
try {
context = new InitialContext();
eh1 = context.lookup("Enterprise1");
System.out.println(eh1.toString());
eh2 = context.lookup("Enterprise1");
System.out.println(eh2.toString());
System.out.println("**************");
}
catch (NamingException ex1) {
}
Object homeRef = null;
for(int i=0;i<10;i++){
homeRef = (i%2==0)?eh1:eh2;
Enterprise1Home enterprise1Home =
(Enterprise1Home)PortableRemoteObject.narrow(homeRef,
Enterprise1Home.class);
System.out.println(enterprise1Home.create().helloWorld(i));
Somebody help me! Am I missing something?
thanks,
Eric
Have you read the white papers (watch out for line
breaks or line wrapping):
http://info.borland.com/devsupport/bes/technotes/clustering/Clustering_BES_AE.html
and
http://info.borland.com/devsupport/bes/faq/all_versions/discovery/how_clients_discover_services.html
In short, what you are seeing is expected behavior. If
you use the Naming Service based load-balancing, you
will see the behavior you describe below.
-krish