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?
The default visibility timeout for a message is 30 seconds. The minimum is 0 seconds. The maximum is 12 hours.
You can view and analyze your queues' metrics from the Amazon SQS console, the CloudWatch console, using the AWS CLI, or using the CloudWatch API. You can also set CloudWatch alarms for Amazon SQS metrics.
You can't view or delete messages in flight, unless you delete/view them from the consumer to whom they are currently 'in flight' to. Messages become 'in flight' when a consumer requests them, so if you want to delete the message, you can, as long as its the same consumer that requested the message in the first place.
Inflight messages are messages in SQS that have been received by a consumer but not yet deleted. Each SQS queue is limited to 120,000 inflight messages, or 20,000 if it is a FIFO queue.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With