[jboss-user] [Beginner's Corner] - Re: Number of stateless beans

piotrekde do-not-reply at jboss.com
Mon Jan 24 13:23:21 EST 2011

piotrekde [http://community.jboss.org/people/piotrekde] created the discussion

"Re: Number of stateless beans"

To view the discussion, visit: http://community.jboss.org/message/582853#582853

I found that I can use org.jboss.ejb3.common.proxy.plugins.async.AsyncUtils in the following way:

public class ComputerBean implements ComputerRemote {
    private ProcessorLocal processor;
    public void startComputations() {
        Random r = new Random();
        while(true) {

Then it is possible to use Future interface to get result (when it will be ready). I tested it - works, but I have also noticed something strange. Let's consider following code:

public class ProcessorBean implements ProcessorLocal {
    private static int COUNTER = 0;
    public void init() {
    public void destroy() {
    public void compute(int i) {
        System.out.println("----------------> " + COUNTER);
        // some dummy computations - it's here only in order to take some time
        double d = 0.3;
        for (int j=0; j<100; j++) {
            d+= 0.2 % 4 + i;

Counter is increased and printed to the console - it looks as SLSB are pooled and their number is increased when needed. 
However, counter is _never_ decremented - even if I stop computations for 15 minutes and then restart it.
I would say that I expected that after some downtime number of pooled SLSB will go to some small number.

Is this something wrong with my code (some hold references etc.) ?


Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110124/4881a3c8/attachment.html 

More information about the jboss-user mailing list