users@glassfish.java.net

Re: MDB: max-pool-size vs. steady-pool-size; too many instances created

From: <glassfish_at_javadesktop.org>
Date: Mon, 30 Nov 2009 11:59:31 PST

I have a similar problem with glassfish-2.1

I am writing an EJB to interface to a command-line driven application, of which there must be at most one (in read/write mode) at any point in time. Thus I want glassfish to create the EJB only when there is work to do, and at most one instance. However, since it is command-line driven, the startup and login time is significant, so I want to keep the command line process hanging around for some time (30 secs) in case there is more work to do.

I have tried:

            <ejb-name>CnrConfigEJB</ejb-name>
            <bean-pool>
                <steady-pool-size>0</steady-pool-size>
                <resize-quantity>1</resize-quantity>
                <max-pool-size>1</max-pool-size>
                <pool-idle-timeout-in-seconds>30</pool-idle-timeout-in-seconds>
            </bean-pool>

And glassfish correctly shows in the GUI that max-pool size is 1, but if I create 2 threads calling the EJB glassfish creates 2 instances. (see attached screen shot)

HOW does one make sure there is only ever at most ONE instance of an EJB created?

Beat regards,
Jacob
[Message sent by forum member 'jablo' ]

http://forums.java.net/jive/thread.jspa?messageID=373924