activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Davies <rajdav...@gmail.com>
Subject Re: ERROR: The Consumer is closed
Date Thu, 13 Dec 2007 06:47:45 GMT

On Dec 11, 2007, at 8:00 PM, caesarkim wrote:

>
> I have a jms client consuming a message from queue in the activeMQ,  
> but for
> some reason, it hangs and throws the following error. I am using  
> ActiveMQ
> 4.1.  My JMS client is using multiple connections.
>
> here is pseudo code.
> JMSClient extends Thread
> {
>   public void run()
>   {
>       ActiveMQConnectionFactory factory = ...
>       Connection conn = factory.createQueueConnection();
>       QueueSession session = conn.createQueueSession();
>       QueueReceiver receiver = session.createReceiver(queue);
>       while(true)
>       {
>            Message m = receiver.receive(1);
>            // Receiving a message.
>       }
>
>
>   }
> }
>
> for(int i = 0; i < 10; i++)
> {
>     new JMSClient().start();
> }
>
>
>
> IllegalStateException: The Consumer is closed at
> org 
> .apache 
> .activemq 
> .ActiveMQMessageConsumer.checkClosed(ActiveMQMessageConsumer.java:672)
>
> Does anybody know why it is thrown and how to prevent this error?
>
> Please correct this if i am using the jms client in a wrong way for
> multi-threading.
>
> I am new to the activeMQ.
>
> Thanks.
>
> -- 
> View this message in context: http://www.nabble.com/ERROR%3A-The-Consumer-is-closed-tp14282085s2354p14282085.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>

Doesn't look like you're calling start on the Connection before  
calling receive



Rob Davies
'Go further faster with Apache Camel!'
http://rajdavies.blogspot.com/







Mime
View raw message