amqp
amqp copied to clipboard
Limit unack message
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
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.
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!
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 !
Share some code. Happy to give it a look.
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.