Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to obtain 2 different SLSB by two succesive call  RSS feed

 
xavier Flamant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I use jboss eap 6.2 under eclipse
I perform a tutorial on EJB and I want to show the difference between a stateless session bean and a statefull session bean. I want demonstrate that the first one keep its state (if it has one) but that 2 successive don't send back necessarily the same SLSB : it send back the SLSB that is ready in the pool. But I don't suceed in obtaining 2 different SLSB by 2 successive call. The system always send me back the same SLSB.

Do you have an idea ? Thanks in advance.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Xavier,
There isn't a way to force it. The container is managing the pool. Speaking of which, make sure you've configured the pool to contain more than one bean.

One way to do this is to write code that does a mini-load test. Start 10 threads and have them each request the SLSB 100 times. Put the returned reference in a set and see how many results you get back.
 
xavier Flamant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jeanne and thank you for your answer.

I did it and I still have one SLSB.

Do you see another solution ?
 
xavier Flamant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again Hello Jeanne,

I tried another thing : I implemented another remote stateless session bean (public class InstanciateBean implements InstanciateBeanInterface) on the server side in the same module as the remote stateless session bean I work on (public class LibrarySessionBean implements LibrarySessionBeanRemote)

In this new stateless session bean I implemented a method to instanciate (in a loop from the client side) the stateless session bean I work on


I measured the time to instanciate (LibrarySessionBean.class.newInstance();) my bean on the server side. it takes around 10 micro seconds

I created 1000 thread (I changed the thread pool size to 1000 on the server side) and the instanciation occur a time between every 120 micro seconds and 17 milli seconds

Apparently The increase of the pool occur when it is stimulated in a time less than 120 micro seconds
 
xavier Flamant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,

I finally understood the general problem.

When you make a remote lookup on a SLSB as a client, the server side send back a proxy. When you use a method on that proxy, the server will use a random SLSB from the pool.

When I was making 2 successive call from the client side, the pool from the server side had a size of one SLSB and I used the same SLSB with it own state. When I create 15 SLSB with 15 different thread, and afterwards I make a remote lookup, the proxy will invoque one of the SLSB from the pool that is made of now several instances (in my case 13). The SLSB used by the lookup will be random among the pool instances- (13 in my case). The discussion is resolved.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!