|
Java™ by example!
|
|
|
How do I receive a message synchronously from a JMS queue?
I used openjms to develop this example. Check out this Q&A first! The following example receives a message 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. It also receives message synchronously: the call to receiver.receive() is a blocking call. However, you can also use the variation receiver.receive(long) where you can specify a timeout. The call will then only block for that specified value. To receive messages asynchronously, check out this Q&A. Main.java:
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|