File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "instance variables in MDB" Watch "instance variables in MDB" New topic

instance variables in MDB

VJ Nairo

Joined: Jan 05, 2006
Posts: 11

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.

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.

I agree. Here's the link:
subject: instance variables in MDB
It's not a secret anymore!