[jboss-user] [EJB 3.0] - Re: Bug: Injected EJB objects instantiated on every MDB call
ariekenb
do-not-reply at jboss.com
Wed Apr 2 12:54:32 EDT 2008
I'm quite new to EJB3, but I can verify I see the same behavior in 4.2.2.GA of the @PostCreate method in a stateless session bean being called every time my MDB gets a message and tries to access the session bean. The JMX console also shows CreateCount growing rapidly for the session bean.
Oddly in my setup (running my own code) I was able to get over a thousand session beans created with the standard -Xms128m -Xmx512m options to JBoss without anything failing. I was also monitoring the number of threads created by JBoss's java process and they did not seem to be growing.
As an experiment, I modified the Stateless stanza in ejb3-aop-interceptors.xml to use StrictMaxPool instead of ThreadlocalPool:
Original:
| <domain name="Stateless Bean">
|
| <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
| @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.ThreadlocalPool.class, maxSize=30, timeout=10000)
| </annotation>
|
My test:
| <domain name="Stateless Bean">
|
| <annotation expr="!class(@org.jboss.annotation.ejb.PoolClass)">
| @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=30, timeout=10000)
| </annotation>
|
After doing this I only see 2 instances of my stateless session bean created, even in tests where it's called from multiple different MDBs and directly from clients. It appears StrictMaxPool is much more conservative in ThreadlocalPool.
doktora - Maybe using StrictMaxPool would be an interesting test/workaround in your case?
To the JBoss experts out there - is it a "problem" that ThreadlocalPool appears to create a new instance of a stateless session bean for every call from an MDB, or is this somehow being managed? What exactly is the difference with StrictMaxPool? Will using StrictMaxPool kill performance?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4141057#4141057
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4141057
More information about the jboss-user
mailing list