BEA Weblogic Question:

Download Job Interview Questions and Answers PDF

Can an MDB be a message producer or both a producer and consumer?

BEA Weblogic Interview Question
BEA Weblogic Interview Question

Answer:

Yes. You have no JMS context inside the MDB so you will need to establish a connection, session and producer yourself. One option is to do this every time you come into the onMessage routine for the MDB. This is sufficient if the message rate is relatively low. The second option is to establish the necessary objects in ejbActivate(). Note that the objects are not serializable so they can't be passivated for a stateful session bean or an entity bean. When the EJB deactivates, you need to close the associated objects. The third option is that you could build up a JMS connection/sender session pool within a startup class complete with your own synchronization and blocking to get a connection. There is an example in the answer to the question "Is it possible to send or receive a message from within a message listener?"

Download BEA Weblogic Interview Questions And Answers PDF

Previous QuestionNext Question
How does concurrency work for message-driven beans?How do I use JTA transactions within an MDB?