0

I get a JMS Queue (JAVAX.JMS) I stablish connection through:

jmsConnect = queueConnectionFactory.createQueueConnection();
jmsSession = jmsConnect.createQueueSession(true,     jmsSession.AUTO_ACKNOWLEDGE);
jmsConnect.start();
connection = queueConnectionFactory.createConnection();
session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
connection.start();

I try to get queued messages with this function:

QueueBrowser browser = session.createBrowser(Queue);
Enumeration e = browser.getEnumeration();
while (e.hasMoreElements()) {
e.nextElement();
cont++;
}
browser.close();
browser = null;

There are at least 1 queued messages, but when the function try to get the total of queued messages, always return 0, some idea of what could be happen?

angelreyes17
  • 81
  • 1
  • 1
  • 5
  • How do you know that there are messages in the queue ? Do you have any console to the MQ to view them ? – Vasu Nov 04 '16 at 05:55
  • Because I see it in JBoss administrative console, my Queue has 1 message queued, the queue is setting as durable, but when I try to monitoring that queue with code, the answer is always 0, the hasMoreElements method always returns false. – angelreyes17 Nov 04 '16 at 15:40

1 Answers1

0

Chances are you have an expired message on the queue. You will still find the messages are in the enqueued count , however when you try to read the message or in your case browse it may not be made available to your application. An example in AMQ turns this up

Ramachandran.A.G
  • 4,788
  • 1
  • 12
  • 24
  • HI! The queue is setting as durable the message never get lost, I have a listener to reestablish communication, and when I turn it on the message queued is received – angelreyes17 Nov 04 '16 at 15:42