It seems to me that a new instance of the EJBs injected in an MDB is created every time
the MDB processes a message.
Below is the code modifications I've made to the EJB3 Trailblazer to verify this. A
RecordManagerBean object is created every time the onMessage method in the CalculatorMDB
is called as can be seen from the console printout of the postConstruct method.
This can have serious implications on memory consumption in a production environment.
I've added the following lines to this file in the EJB3 Trailblazer source code:
./src/trail/injection/RecordManagerBean.java
import javax.annotation.PostConstruct;
| import javax.annotation.PreDestroy;
| import javax.ejb.PostActivate;
| import javax.ejb.PrePassivate;
| import org.jboss.logging.Logger;
...
private static final Logger log = Logger.getLogger(RecordManagerBean.class);
| @PostConstruct public void postConstruct() { log.info("++++++++++++
postConstruct +++++++++++ "); }
| @PreDestroy public void preDestroy() { log.info("preDestroy **********");
}
| @PrePassivate public void prePassivate() { log.info("prePassivate
**********"); }
| @PostActivate public void postActivate() { log.info("postActivate
**********"); }
postConstruct is called on every MDB call, none of the other methods seem to be executed
ever.
Is this a bug or am I missing something?
Cheers
Dok
P.S.
JBoss [Trinity] 4.2.1.GA (build: SVNTag=JBoss_4_2_1_GA date=200707131605)
Java version: 1.5.0_13,Apple Computer, Inc.
OS-System: Mac OS X 10.4.11,i386
JBoss is started with -c all and the EJB3Trail.jar is put in all/farm/
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4138516#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...