Search code examples
jmsjms-session

Who manages a JMS session on the consumer side


If I have a JMS queue and I wish to put a message on the queue from a publishing client, I need to first open a session, get the queue from its jndi name and then send the message to the queue.

But on the consumer side, how come I do not manually need to open a session and receive the message. Does the container always keep one open session per MDB (considering one MDB listening on one queue)


Solution

  • If you're using MDB's, which are container-managed objects, the connection, session, queue/topic, and actual consumer are all managed by the container.

    You just write the code for onMessage(Message m), that's it.