How to avoid duplication of Total delivery unacked messages?
Few messages got stuck in the queue for delivered unacked messages, only if the application restarts the messages are removed from the queue. Will the broker tries to send the stuck messages again and cause a duplication of messages and if yes, how to avoid it when the application restarts or any other possible solution that could be done here?
Answers
-
Hi @himanshu007, welcome to the Community!
For our knowledge, which API(s) are you using?
Messages will be left on the queue until the receiving/consuming application acknowledges them. If it disconnects/restarts without ACKing, the messages will be delivered again b/c the app didn't ACK yet. This is VERY important for Guaranteed delivery. It's not really duplication b/c the application never told the broker it had finished processing them. Otherwise you would get LOST messages, much worse.
So your consumer needs to
ack()
when it has finished processing/storing/forwarding the messages that it is receiving.Note that in most Solace APIs, there is a "redelivered" boolean flag that will be set on messages if the broker has to send the message again. There's also a newer feature where the message will have a counter to tell the app how many times the broker has resent.
But yeah,
ack()
your messages when you have finished with them. 👍🏼0