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.
posted 10 years ago
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.