Hi Rafael,

I think that the spec extract that you quote is addressing a different issue 
from how I understood Rajith's original ask. 

I believe that the extract you quote below is talking about what happens when I 
consume messages via different routes from the same MessageConsumer. That is, 
if I set MessageListener, ML1, on MessageConsumer, MC, and I then I also 
receive messages synchronously by calling MC.receive() or I set another 
MessageListener with MC.setMessageListener(ML2) then I think the spec is saying 
that the behavior is undefined, i.e., how messages are distributed between ML1, 
ML2 and the synchronous receives is undefined. 

I interpreted the original description as something different, namely I create 
a Connection, create a Session, start the Connection and then create a 
MessageConsumer with a MessageListener, i.e., the connection had no 
MessageListeners at the time it was started and then they were latterly added. 
My previous statement was that I believe that this sequence of events is 
legitimate and these new MessageListeners should begin to receive messages. I 
interpreted Rajith's original mail as saying that the implementation didn't do 
this and I would classify that as a bug.

Thanks,

Dave.

-----Original Message-----
From: Rafael Schloming [mailto:[email protected]] 
Sent: Wednesday, February 18, 2009 11:19 AM
To: [email protected]
Subject: Re: Clarification on JMS Client behaviour w.r.t message listeners

Rajith Attapattu wrote:
> Aidan,
> 
> I came across this when I wrote a simple test to figure out another issue.
> Basically I did the following.
> 
> create connection
> start the connection
> create a session
> create a destination, using that create a MC and a MP.
> set a MessageListener to the MC.
> send messages using MP.
> 
> When the session tries to deliever the messages it throws an
> IllegalStateException as the dispatcher thread is null.
> 
> Let me create a JIRA and then attach the test case and the stack trace.

Strictly speaking I believe the JMS api-doc says that the behavior in 
the above scenario is undefined. From the api-doc:

"The effect of calling MessageConsumer.setMessageListener  while 
messages are being consumed by an existing listener or the consumer is 
being used to consume messages synchronously is undefined."

I think this means that throwing an IllegalStateException is valid, 
however that doesn't mean we can't do something a bit more graceful if 
we want to.

--Rafael


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to