This content has been marked as final. Show 3 replies
1 person found this helpful
919856 wrote:Just to check: So if you use receive(2000) your test works every time, but if you use receiveNoWait() it sometimes fails to receive the message
Any thoughts on why this behavior would happen?
If so this is because of the way your JMS provider has implemented receiveNoWait(); This method is required to return immediately, which isn't enough time for the message to arrive from the server.
Thanks for your quick response. That is exactly the behavior i see. Receive with no wait fails at times but receive with a wait of even 1 second seems to work.
I saw this with ActiveMQ using both the embedded broker and an external broker.
It's best to avoid receiveNoWait() for the reason you've discovered.
I'll try to clarify this in JMS 2.0. I've just logged this as