Using a JMS Session from different threads
        Posted  
        
            by Evan
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Evan
        
        
        
        Published on 2010-03-22T08:05:54Z
        Indexed on 
            2010/03/22
            8:11 UTC
        
        
        Read the original article
        Hit count: 365
        
From the javadoc for Session it states:
A Session object is a single-threaded context for producing and consuming messages.
So I understand that you shouldn't use a Session object from two different threads at the same time. What I'm unclear on is if you could use the Session object (or children such as a Queue) from a different thread than the one it created.
In the case I'm working on, I'm considering putting my Session objects into a pool of available sessions that any thread could borrow from, use, and return to the pool when it is finished with it.
Is this kosher?
(Using ActiveMQ BTW, if that impacts the answer at all.)
© Stack Overflow or respective owner