Based on this forum post
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=127090
the create/close a connection and session per JMS message is considered an anti-pattern.
For reference, we are using JBoss EAP 4.3.0 and JBoss Messaging 1.4.0.SP3
What is the best practice for a Stateless Session Bean that sends JMS messages in response to some (high throughput) external stimulus?
Should there be one Session and Connection per Bean instance, potentially creating hundreds of these references depending on the size of the EJB pool?
Or are the Session and Connection objects thread-safe, and assuming that the application is not calling close() on them, can one Session/Connection per JMS destination be used safely?
We currently use the connection/session-per-bean-instance model, but are wondering if we are creating unnecessary overhead by doing so. Profiling the heap shows thousands of JBossSession and JBossConnection objects because the EJB pools have expanded to handle heavy load.
Thanks for any pointers on best-practice.
This probably best aimed at the App server developers, however this article may help http://www.jboss.org/community/wiki/ShouldIcacheJMSconnectionsandJMSsessions