I am developing an MDB in JBoss 3.2.3 that receives a Message then posts a response to a Destination.
To improve performance, should I maintain a reference to a single JMS Connection throughout the life of the bean and reuse this Connection to create a new Session for each posted response? I have read in (http://www.huihoo.com/jboss/online_manual/3.0/ch08s32.html) that this is the preferred approach and also that Sessions are pooled. I have not seen any evidence in the src regarding Session pooling and I am concerned that maintaining an open connection for each MDB may exhaust resources. Thanks in advance for your thoughts on the JMS internals and pooling.
public class ForwardingWorkFlowBean extends MDB, MessageListener { private QueueConnection connection; private Queue queue; public void ejbCreate() { Context jndiContext = new InitialContext(); QueueConnectionFactory factory = (QueueConnectionFactory)jndiContext.lookup("XXXX"); this.queue = (Queue)jndiContext.lookup("YYYYY"); this.connection = factory.createQueueConnection(); } public void ejbRemove() { this.connection.close(); } public void onMessage(Message message) { // do blah QueueSession session = this.connection.createQueueSession(); QueueSender sender = session.createSender(this.queue); sender.send(responseMsg); session.close(); } }