You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by jaya_srini <jy...@Hotmail.com> on 2008/08/06 06:05:48 UTC

Re: JMS Threading Restriction

hi

I had a follow up question on this...

If I publish a message within onMessage() then are the following true?

1) if the message is published within onMessage() in the same thread i.e.the
JMS provider owns the onMessage thread and the publish happens in that same
thread, then the message can be published with the same Session.

2) If the message is published in onMessage() but in a separate thread,For
instance, onMessage() calls processMessage() which spawns a separate thread
and the publish happens in that separate thread, then the message needs to
be published with a *different* session

Can someone  confirm/correct the above?

thanks!
jaya


rajdavies wrote:
> 
> 
> 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
> 
> 
> 
> 
> cheers,
> 
> Rob
> 
> http://open.iona.com/products/enterprise-activemq
> http://rajdavies.blogspot.com/
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JMS-Threading-Restriction-tp17834428p18843895.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.