Rajith Attapattu wrote:
On Wed, Feb 18, 2009 at 2:19 PM, Rafael Schloming <[email protected]> wrote:
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.

Rafi, the important point here is that when the message listener is
set there is no existing listener or a synchronous receive in
progress.
In other words you haven't yet used the Message Consumer to receive
messages synchronously or asynchronously.
But the message consumer is created only after connection.start is called.

So I guess what you are saying is that after connection.start is
called any message consumer created will be interepreted as consuming
messages synchronously ?
Did I understand you correctly?

Yes, I believe message listener == null is equivalent to "being used to consume messages synchronously".

I believe the general idea is that you aren't supposed to modify message consumers at all while the connection is started. You're supposed to stop the connection, change the message listeners, set up new consumers, etc, and then start the connection again.

If you don't stop the connection then you're essentially changing how messages are handled on the fly while messages are being asynchronously delivered, and so the consequences may be unpredictable.

--Rafael


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

Reply via email to