This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes instance variables in MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "instance variables in MDB" Watch "instance variables in MDB" New topic
Author

instance variables in MDB

VJ Nairo
Greenhorn

Joined: Jan 05, 2006
Posts: 11
HI,

I have a scenario in which I need to associate one MDB with one processing class which will actually process the message. The number of instances should be the same as the number of instances of the processing classes. I plan to do this by creating the instance of the processing class in the MDB's create() method. I presume this will work as MDBs cannot mess with each others instance variables.

Is this a correct programming practise and will it work. Let me know your thoughts.

Thanks,
Vijay.
Andreas Schaefer
Ranch Hand

Joined: Feb 13, 2006
Posts: 63
Yes, that is perfectly fine. You do not need to postpone the creation of your processing class to the ejbCreate() method but can do this even in the constructor. Only if you need any EJB resources like the MDB context etc. you need to place that code in the ejbCreate() method.

-Andy
 
 
subject: instance variables in MDB
 
Similar Threads
Listener instances
MDB and Stateless session bean combination
shared count variables for instances
Statics and serialization
JMS and instance pool of msg driven beans