Announcement Announcement Module
No announcement yet.
Using JmsTemplate outside a container Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using JmsTemplate outside a container


    We've been using the JmsTemplate for some time now to send messages, e.g.,

    jms_template.send(workflow_status_topic, new MessageCreator() {
    public Message createMessage(Session session) throws JMSException {
    return session.createObjectMessage(status);

    And we've run this code WITHIN a JEE container, taking advantage of the fact that the container vendor supports Session wrappers (i.e., pooling).

    Now we want to use this same jms_template technique to send messages OUTSIDE a container (from multiple user-managed threads) and so we no longer have the container feature that provides Session pooling for us and so my question is: is there a big performance penality because the JmsTemplate always creates a new Session, uses it to send the message, then destroys (ie. closes()) the Sessson on every message send?

    Btw- Our Sessions are setup to be non-transacted

    Would a better alternative be to have each user-thread directly manage Sessions itself (using all the JMS api gory details), instead of using the JmsTemplate approach in this case (i.e., running outside a container)?

    Or maybe its possible for us to write our own Session pooling mechanism? But what exactly does that imply, i.e., we need to intercept the close() call on the Session and then do what to the Session?

    any ideas would be greatly appreciated!


  • #2
    You may have a look at jencks framework. It offers necessary pooling facilities.