activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Davies <>
Subject Re: JMS Threading Restriction
Date Sat, 14 Jun 2008 06:12:45 GMT

On 14 Jun 2008, at 01:50, Joshua Smith wrote:

> All-
> I'm reading a number of references on JMS written some time between  
> 2001 and
> now. The challenge that comes with that is knowing which things are  
> still
> true today and which things were describing the state of affairs at  
> that
> time. I found the following paragraph in the O'reilly Java Message  
> Service
> (First Edition) book written in 2001 on p. 32. Can anyone confirm  
> that this
> is still an accurate description of JMS?
> "The Chat application ((which is what they use for their JMS example  
> in the
> book)) uses a separate session for the publisher and subscriber,  
> pubSession
> and subSession, respectively. This is due to a threading restriction  
> imposed
> by JMS. ***According to the JMS specification, a session may not be  
> operated
> on my more than one thread at a time.*** In our example, two threads  
> of
> control are active: the default main thread of the Chat application  
> and the
> thread that invokes the onMessage() handler. The thread that invokes  
> the
> onMessage() handler is owned by the JMS provider. Since the  
> invocation of
> the onMessage() handler is asynchronous, it could be called while  
> the main
> thread is publishing a message in the writeMessage() method. If both  
> the
> publisher and subscriber had been created by the same session, the two
> threads could operate on these methods at the same time; in effect,  
> they
> could operate on the same TopicSession - a condition that is  
> prohibited."
> (emphasis mine)
> Thanks,
> Joshua Smith

Hi Joshua,

I used to have a copy of that book somewhere!
Yep - its still an accurate description of JMS



View raw message