You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Jeroen van Bergen <va...@gmail.com> on 2008/02/11 14:58:33 UTC

Consumer not consuming messages

I'm running a very basic instance of AMQ 5.0.0: just the supplied sample
configuration, starting the broker with bin\activemq. My client application
(Java SE) produces and consumes messages on a single queue. Both the
producer and the consumer use the
session.createXXX(session.createQueue(queueName), null) call to create a
producer and a consumer, respectively.

The producer is happily producing messages. I can browse them using the web
front end supplied with ActiveMQ. When I add a QueueBrowser to the consuming
class it can see the messages in the queue. The consumer is not picking up
any message at all. Relevant code:

QueueBrowser browser =
session.createBrowser(session.createQueue(queueName));
Enumeration enumeration = browser.getEnumeration();
while (enumeration.hasMoreElements()) {
    Message message = (Message) enumeration.nextElement();
    logger.debug("Saw message " + message.getJMSMessageID());
}
logger.debug(getName() +  " is requesting messages from " + queueName);
Message message = consumer.receiveNoWait();
if (message != null) {
    logger.debug("Retrieved message " + message.getJMSMessageID());
}

The consumer is started before the producer and they run in seperate threads
on a 1.6.0_03 Sun JVM on Windows XP Pro SP2.

What might be causing this behaviour? Do I have to supply credentials before
a consumer is allowed to actually consume messages? 

Thanks in advance for any response.
-- 
View this message in context: http://www.nabble.com/Consumer-not-consuming-messages-tp15411975s2354p15411975.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Consumer not consuming messages

Posted by Jeroen van Bergen <va...@gmail.com>.

James.Strachan wrote:
> 
>>Do you just do one call to receiveNoWait() then nothing else? It
>>sometimes takes up to a second for the first message to arrive?
> 

It was a repeated call in a loop. The problem has been resolved. I'm not
quite sure what the root cause was, but after some experiments the
MessageConsumer is happily consuming messages. I still don't understand why
the QueueBrowser saw the message while the MessageConsumer did not pick up
anything. This is merely of academic interest to me now. Thank you for your
time.
-- 
View this message in context: http://www.nabble.com/Consumer-not-consuming-messages-tp15411975s2354p15516840.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Consumer not consuming messages

Posted by James Strachan <ja...@gmail.com>.
On 13/02/2008, Jeroen van Bergen <va...@gmail.com> wrote:
>
>
>
> wha wrote:
> >
> > I can't see your entire code.
> > I don't know if you have a setMessageListener(YourConsumerClass) for your
> > consumer.
> > Your consumer class must implement MessageListener.
> >
>
> What I gathered from the JMS API documentation is that a call to receive()
> of a Consumer (as defined in the JMS API) amounts to the same thing.
> Furthermore I want to have control over when my consumer actually consumes
> messages, so I'm using receiveNoWait() to consume messages from the queue.

Do you just do one call to receiveNoWait() then nothing else? It
sometimes takes up to a second for the first message to arrive?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Consumer not consuming messages

Posted by Rob Davies <ra...@gmail.com>.
Can you attach a test case for this ?

On Feb 13, 2008, at 7:54 AM, Jeroen van Bergen wrote:

>
>
>
> wha wrote:
>>
>> I can't see your entire code.
>> I don't know if you have a setMessageListener(YourConsumerClass)  
>> for your
>> consumer.
>> Your consumer class must implement MessageListener.
>>
>
> What I gathered from the JMS API documentation is that a call to  
> receive()
> of a Consumer (as defined in the JMS API) amounts to the same thing.
> Furthermore I want to have control over when my consumer actually  
> consumes
> messages, so I'm using receiveNoWait() to consume messages from the  
> queue.
>
> -- 
> View this message in context: http://www.nabble.com/Consumer-not-consuming-messages-tp15411975s2354p15450871.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


Re: Consumer not consuming messages

Posted by Jeroen van Bergen <va...@gmail.com>.


wha wrote:
> 
> I can't see your entire code.
> I don't know if you have a setMessageListener(YourConsumerClass) for your
> consumer.
> Your consumer class must implement MessageListener.
> 

What I gathered from the JMS API documentation is that a call to receive()
of a Consumer (as defined in the JMS API) amounts to the same thing.
Furthermore I want to have control over when my consumer actually consumes
messages, so I'm using receiveNoWait() to consume messages from the queue.

-- 
View this message in context: http://www.nabble.com/Consumer-not-consuming-messages-tp15411975s2354p15450871.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Consumer not consuming messages

Posted by wha <wi...@cgi.com>.
I can't see your entire code.

I don't know if you have a setMessageListener(YourConsumerClass) for your
consumer.

Your consumer class must implement MessageListener.




Jeroen van Bergen wrote:
> 
> 
> 
>>>> The producer is happily producing messages. I can browse them using the
>>>> web
>>>> front end supplied with ActiveMQ. When I add a QueueBrowser to the
>>>> consuming
>>>> class it can see the messages in the queue. The consumer is not picking
>>>> up
>>>> any message at all.
>> 
>>>Have you hit this FAQ entry?
>>>http://activemq.apache.org/i-am-not-receiving-any-messages-what-is-wrong.html
>> 
> Thanks for the hint. However, the connection was started. Relevant code:
> QueueConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory(url);
> Connection connection = connectionFactory.createConnection();
> session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
> consumer = session.createConsumer(session.createQueue(queueName));
> connection.start();
> 
> I'm still very confused why a QueueBrowser can see messages in the queue
> while a Consumer does not pick up any. The ActiveMQ logfile shows nothing
> special. Anything else I can look at?
> 

-- 
View this message in context: http://www.nabble.com/Consumer-not-consuming-messages-tp15411975s2354p15444805.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Consumer not consuming messages

Posted by Jeroen van Bergen <va...@gmail.com>.


>>> The producer is happily producing messages. I can browse them using the
>>> web
>>> front end supplied with ActiveMQ. When I add a QueueBrowser to the
>>> consuming
>>> class it can see the messages in the queue. The consumer is not picking
>>> up
>>> any message at all.
> 
>>Have you hit this FAQ entry?
>>http://activemq.apache.org/i-am-not-receiving-any-messages-what-is-wrong.html
> 
Thanks for the hint. However, the connection was started. Relevant code:
QueueConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(url);
Connection connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
consumer = session.createConsumer(session.createQueue(queueName));
connection.start();

I'm still very confused why a QueueBrowser can see messages in the queue
while a Consumer does not pick up any. The ActiveMQ logfile shows nothing
special. Anything else I can look at?
-- 
View this message in context: http://www.nabble.com/Consumer-not-consuming-messages-tp15411975s2354p15439696.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Consumer not consuming messages

Posted by David Siefert <si...@gmail.com>.
LOL!  I had just finished writing a test that uses a QueueBrowser and had
the same problem, so based on the prior issue I posted I put in a start()
connection and it worked.

On Feb 11, 2008 9:12 AM, James Strachan <ja...@gmail.com> wrote:

>  On 11/02/2008, Jeroen van Bergen <va...@gmail.com> wrote:
> >
> > I'm running a very basic instance of AMQ 5.0.0: just the supplied sample
> > configuration, starting the broker with bin\activemq. My client
> application
> > (Java SE) produces and consumes messages on a single queue. Both the
> > producer and the consumer use the
> > session.createXXX(session.createQueue(queueName), null) call to create a
> > producer and a consumer, respectively.
> >
> > The producer is happily producing messages. I can browse them using the
> web
> > front end supplied with ActiveMQ. When I add a QueueBrowser to the
> consuming
> > class it can see the messages in the queue. The consumer is not picking
> up
> > any message at all. Relevant code:
> >
> > QueueBrowser browser =
> > session.createBrowser(session.createQueue(queueName));
> > Enumeration enumeration = browser.getEnumeration();
> > while (enumeration.hasMoreElements()) {
> >     Message message = (Message) enumeration.nextElement();
> >     logger.debug("Saw message " + message.getJMSMessageID());
> > }
> > logger.debug(getName() +  " is requesting messages from " + queueName);
> > Message message = consumer.receiveNoWait();
> > if (message != null) {
> >     logger.debug("Retrieved message " + message.getJMSMessageID());
> > }
> >
> > The consumer is started before the producer and they run in seperate
> threads
> > on a 1.6.0_03 Sun JVM on Windows XP Pro SP2.
> >
> > What might be causing this behaviour? Do I have to supply credentials
> before
> > a consumer is allowed to actually consume messages?
> >
> > Thanks in advance for any response.
>
> Have you hit this FAQ entry?
>
> http://activemq.apache.org/i-am-not-receiving-any-messages-what-is-wrong.html
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>

Re: Consumer not consuming messages

Posted by James Strachan <ja...@gmail.com>.
On 11/02/2008, Jeroen van Bergen <va...@gmail.com> wrote:
>
> I'm running a very basic instance of AMQ 5.0.0: just the supplied sample
> configuration, starting the broker with bin\activemq. My client application
> (Java SE) produces and consumes messages on a single queue. Both the
> producer and the consumer use the
> session.createXXX(session.createQueue(queueName), null) call to create a
> producer and a consumer, respectively.
>
> The producer is happily producing messages. I can browse them using the web
> front end supplied with ActiveMQ. When I add a QueueBrowser to the consuming
> class it can see the messages in the queue. The consumer is not picking up
> any message at all. Relevant code:
>
> QueueBrowser browser =
> session.createBrowser(session.createQueue(queueName));
> Enumeration enumeration = browser.getEnumeration();
> while (enumeration.hasMoreElements()) {
>     Message message = (Message) enumeration.nextElement();
>     logger.debug("Saw message " + message.getJMSMessageID());
> }
> logger.debug(getName() +  " is requesting messages from " + queueName);
> Message message = consumer.receiveNoWait();
> if (message != null) {
>     logger.debug("Retrieved message " + message.getJMSMessageID());
> }
>
> The consumer is started before the producer and they run in seperate threads
> on a 1.6.0_03 Sun JVM on Windows XP Pro SP2.
>
> What might be causing this behaviour? Do I have to supply credentials before
> a consumer is allowed to actually consume messages?
>
> Thanks in advance for any response.

Have you hit this FAQ entry?
http://activemq.apache.org/i-am-not-receiving-any-messages-what-is-wrong.html

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com