activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dj_jay_smith <dj_jay_sm...@hotmail.com>
Subject consumer.receive always returns null
Date Wed, 27 Jan 2010 14:22:30 GMT

Hi All,


I am starting to write a simple program to read message from a topic that I
have created and posted message to from anothe program.  But for some reason
when I call "consumer.receive(10000)" then I always get null returned even
though there are messages on the Topic ready to be collected.

I am sure that it is a simple stupid mistake somewhere, but I can not see it
so help is needed.  I am new to JMS so I appreciate any help that can be
offered.

My code;

Context jndiContext = new InitialContext();        
TopicConnectionFactory connectionFactory
=TopicConnectionFactory)jndiContext.lookup(this.connFactory);

Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic dest = (Topic)jndiContext.lookup(this.destination);

connection.start();
MessageConsumer consumer = session.createConsumer(dest);

then later;

Message mess = consumer.receive(10000);  //returns null!

I can see my consumer connect to the topic (Number Of Consumers in activemq
admin console is incremented), and I have several message waiting but they
are never collected and I don't know why!

I am running activemq on a remote server, but it can't be a connection
problem as I am able to send messages, access the admin console and I would
expect an exception to be thrown if this was the case.

Thanks for you help.

-- 
View this message in context: http://old.nabble.com/consumer.receive-always-returns-null-tp27340066p27340066.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message