Reputation: 830
Given an Amazon SQS message, is there a way to tell if it is still in flight via the API? Or, would I need to note the timestamp when I receive the message, subtract that from the current time, and check if that is less than the visibility timeout?
Upvotes: 10
Views: 6765
Reputation: 269081
The normal flow for using Amazon Simple Queueing Service (SQS) is:
SendMessage
(it can remain in the queue for up to 14 days)ReceiveMessage
to retrieve a message from the queue (no guarantee of first-in-first-out)DeleteMessage
(it can also call ChangeMessageVisibility
to extend the time until it times-out)It is not possible to obtain information about a specific message. Rather, the application asks for a message (or a batch of messages), upon which the message becomes invisible (or 'in flight'). This also gives access to a ReceiptHandle
that can be used with DeleteMessage
or ChangeMessageVisibility
.
The closest option is to call GetQueueAttributes
. The value for ApproximateNumberOfMessagesNotVisible
will indicate the number of in-flight messages but it will not give insight into a particular message.
Upvotes: 20