1 Reply Latest reply on Sep 28, 2009 6:50 AM by Andy Taylor

    Stateless Session Bean and JMS best practice

    Andy Byer Newbie

      Based on this forum post

      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.