2

My program will be receiving messages rather slowly; and I want to them to persist in the queue until I have receive all of them and acknowledge all of them. I don't know if I have enough messages until I receive a bunch of them.

My question: will the queue block, waiting for the acknowledgement from the first message before delivering the second?

gregory
  • 10,969
  • 2
  • 30
  • 42
Gerry
  • 1,031
  • 1
  • 14
  • 30

2 Answers2

0

Well I ran a test one this using the sample producer/consumer code. The consumer actually has some code (if you switch over to ClientAcknowledge). It receives a bunch of messages (10 of them) and only acks the last one.

Gerry
  • 1,031
  • 1
  • 14
  • 30
0

When setting the acknowledge mode to Session.CLIENT_ACKNOWLEDGE you can get as many messages you need. The messages will be locked on the server, so no other consumer can retrieve them meanwhile. So the answer is no, the queue won't block (even thu there might be provider-specific settings that can do that, which I don't know).

However, you can acknowledge only all at once. So when you have received 10 messages, and you acknowledge one of them (doesn't matter which), all messages will be acknowledged.

Check for your reference Controlling Message Acknowledgment

Dag
  • 10,079
  • 8
  • 51
  • 74