Reputation:
When a message is sent using sendMessage()
function with a MessageDeduplicationId
to prevent duplicates.
However, the sendMessage function always returns true. In other words, the sendMessage
function always returns a value that says message successfully sent to SQS, however the message actually is not available.
I change a field 'sent_to_sqs
' in the DB based on the sendMessage()
return value.
Can anybody help me?
Upvotes: 0
Views: 994
Reputation: 178956
The design assumption is that if you send a message with the same deduplication-id, then that is the exact same message you already sent (otherwise, it should not have the same deduplication-id), so SQS pretends to accept it again, on the assumption that something must have gone wrong on your side, preventing you from realizing that the message was already submitted the first time.
“the
sendMessage
function always returns a value that says message successfully sent to SQS”
Yes, because it already was, earlier.
SQS doesn't verify that the message is actually a duplicate -- it assumes that it is, because you've claimed it must be by submitting the same deduplication-id within the 5 minute window. If the message has already been handled, then it will not be available on the queue, by design.
Message Deduplication ID
The token used for deduplication of sent messages. If a message with a particular message deduplication ID is sent successfully, any messages sent with the same message deduplication ID are accepted successfully but aren't delivered during the 5-minute deduplication interval.
Upvotes: 3