amqp icon indicating copy to clipboard operation
amqp copied to clipboard

Limit unack message

Open jonathanroze opened this issue 4 years ago • 5 comments

Hi,

How can I limit my receiver to receive only 5 or another number of unack message to avoid to receive all messages that are in the queue ?

Thanks

jonathanroze avatar Sep 10 '19 20:09 jonathanroze

I believe if you set LinkCredit as show in this example, it will limit your receiver from receiving more than the number specified in LinkCredit before providing a disposition for a message.

Also, there's pretty solid docs associated with that option here: https://godoc.org/pack.ag/amqp#LinkCredit.

devigned avatar Sep 10 '19 21:09 devigned

Thanks for your time Devigned, i already tried this property and my receive all messages that are in the queue !

I'm using Amazon MQ!

jonathanroze avatar Sep 11 '19 07:09 jonathanroze

I tried to put sleep into my onMessage function and credit set to 10, but in this case, i can read just one by one message !

jonathanroze avatar Sep 11 '19 09:09 jonathanroze

Share some code. Happy to give it a look.

devigned avatar Sep 11 '19 14:09 devigned

I agree, without the code it's difficult to advise on what might be happening.

onMessage isn't part of this library's API, but you'd need to be handling them in separate goroutines to get more than one at a time.

For what you're asking for to work you also need to be negotiating amqp.LinkSenderSettle(amqp.ModeUnsettled) otherwise the broker could be sending you messages that are already settled and there's nothing to ack.

vcabbage avatar Sep 11 '19 15:09 vcabbage