Index:Java 2 Enterprise Edition (J2EE):Java Message Service (JMS)

How do I receive a message asynchronously from a JMS queue?

Chat with random people around the world, auto-translating languages!

I used openjms to develop this example. Check out this Q&A first!

The following example receives a message asynchronously from the testqueue queue. The acknowledgement mode is set to AUTO_ACKNOWLEDGE, which means that the session will automatically acknowledges a client's receipt of a message. With asynchronous reception, the onMessage method of your implementation of MessageListener is called when there is a message available on the queue.

To receive message synchronously, check this Q&A.

Main.java:

This code sample is only viewable to esus.com members
Login or become a member!




Further Information
Author of answer: Joris Van den Bogaert

Comments to this answer are only viewable by members. Login or become a member!