activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonas Lim <j...@exist.com>
Subject Re: Cannot synchronously receive a message when a MessageListener is set
Date Fri, 18 Jan 2008 03:15:56 GMT
Hi Jean,

A MessageListener should only be set if you are using an asynchronous 
consumer, you will need to comment out 
"subscriber.setMessageListener(ml);" in your code if you're going to be 
using a synchronous consumer (ie. consumer.receive) which looks to be 
the case in your sample code. afaik, a consumer can only either receive 
messages synchronously or asynchronously but not both.

Regards,
Jonas



JS75 wrote:
> Dear All:
> I tried to receive message from topic, however, I got exception below.
>      [java]      [java] javax.jms.IllegalStateException: Cannot
> synchronously receive a message when a MessageListener is set
>      [java]      [java]         at
> org.apache.activemq.ActiveMQSession.checkMessageListener(ActiveMQSession.java:1723)
>      [java]      [java]         at
> org.apache.activemq.ActiveMQMessageConsumer.checkMessageListener(ActiveMQMessageConsumer.java:631)
>      [java]      [java]         at
> org.apache.activemq.ActiveMQMessageConsumer.receive(ActiveMQMessageConsumer.java:468)
>
> In my code, I initital a topic subsrciber to receive a message and set it
> with one message listener.
> subscriber.setMessageListener(ml);  // ml is the message listener
>
> I have no idea why throws this exception..
>
> Sincerely,
> Jean
>   

Mime
View raw message