Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I tell if an Amazon SQS message is still in flight?

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?

like image 994
roark Avatar asked Aug 03 '15 16:08

roark


People also ask

How long do messages stay in flight SQS?

The default visibility timeout for a message is 30 seconds. The minimum is 0 seconds. The maximum is 12 hours.

How do I check the status of a SQS queue?

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.

How do I check my messages on a flight?

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.

What are the inflight messages in case of Amazon SQS?

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.


1 Answers

The normal flow for using Amazon Simple Queueing Service (SQS) is:

  • A message is pushed onto a queue using SendMessage (it can remain in the queue for up to 14 days)
  • An application uses ReceiveMessage to retrieve a message from the queue (no guarantee of first-in-first-out)
  • When the application has finished processing the message, it calls DeleteMessage (it can also call ChangeMessageVisibility to extend the time until it times-out)
  • If the application does not delete the message within a pre-configured time period, SQS makes the message reappear on the queue
  • If a message is retrieved from the queue more than a pre-configured number of times, the message can be moved to a Dead Letter queue

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.

like image 68
John Rotenstein Avatar answered Sep 30 '22 03:09

John Rotenstein