This is the listener startup code, started by a servlet listener. The 'Queue
Setup done' is printed to the console, no errors:
public TestMyQueueListener startTestQueueConsumer() {
try {
if (testMyQueueListener == null) {
testMyQueueListener = new TestMyQueueListener();
}
InitialContext initCtx = new InitialContext();
//Context envContext = (Context)
initCtx.lookup("java:comp/env");
QueueConnectionFactory connectionFactory =
(QueueConnectionFactory)
initCtx.lookup("openejb:Resource/MyJmsConnectionFactory");
QueueConnection connection =
connectionFactory.createQueueConnection();
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer((Destination)
initCtx.lookup("openejb:Resource/MyQueue"));
consumer.setMessageListener(testMyQueueListener);
connection.start();
System.out.println("Queue Setup done");
} catch (NamingException ex) {
ex.printStackTrace();
} catch (JMSException ex) {
ex.printStackTrace();
}
return testMyQueueListener;
}
public class TestMyQueueListener implements MessageListener {
public void onMessage(Message message) {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
try {
System.out.println(textMessage.getText());
} catch (JMSException ex) {
ex.printStackTrace();
}
}
}
}
--
View this message in context:
http://activemq.2283324.n4.nabble.com/onmessage-not-picking-up-messages-tp4524534p4526352.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.