I'd like to know what the correct method of browsing a queue using the core API is.
I have found using receiveImmediate() to be unreliable when browsing a queue. So instead I have been using receive(100). If the timeout is too high, then browsing takes forever, but if the timeout is too low, then I run the risk of not seeing all the messages in the queue. I did see this: https://jira.jboss.org/browse/HORNETQ-250 which seems to say that receiveImmediate() is not reliable when browsing, but this information is missing from the documentation (and javadoc).
I tried an alternate method of browsing using management calls (listMessagesAsJSON), but I've run into other timing issues with it that makes it seem less reliable.
I have also noticed that there is sometimes a delay between submitting a message and being able to browse or consume it, even though I have disabled buffering and enabled block-on-acknowledge and block-on-durable-send (in this case the messages/queues are durable). The only workaround for this I have found is to increase the timeout when receiving the message.
Anyhow, I'd just like to hear some feedback about whether I'm going about this the wrong way, or if anyone has any tips related to queue browsing or blocking until a message exists in the queue when sending a message.
just vreate your conumer with browseOnly = true.
i.e. clientSession.createConsumer(final SimpleString queueName, final boolean browseOnly) throws HornetQException