Tarmac

How to View SQS Messages Without Deleting Them

Receiving an SQS message does not delete it. View messages in the AWS Console, the AWS CLI, or Tarmac, and give them back to your consumers when you are done.

Viewing a message does not delete it. SQS deletes a message only when someone calls DeleteMessage with its receipt handle, or when the message outlives the queue's retention period.

To view a message, you receive it and do not delete it. It goes back on the queue when its visibility timeout ends. Or you can release it at once.

What viewing changes

Viewing does not delete, but it still changes the queue. SQS has no read-only way to look at a message.

  • Your consumers wait. A received message is hidden for the visibility timeout. Your consumers, including a Lambda trigger, cannot process it until it comes back.
  • The receive count goes up. Each receive adds one to ApproximateReceiveCount. SQS counts a message that was received but not deleted as a failed receive. With a redrive policy, enough views move the message to the dead-letter queue. The same happens when consumers receive messages they do not want. See How to Filter SQS Messages So Each Consumer Gets Only Its Own.
  • A FIFO group stops. On a FIFO queue, while you hold a message, SQS returns no other message from the same message group. The whole group waits for you.

So view with a short visibility timeout, release what you received when you are done, and check the receive count before you view the same message again.

In the AWS Console

  1. Open the queue in the SQS console.
  2. Choose Send and receive messages.
  3. Choose Poll for messages.
  4. Open a message to read its body and attributes.

Do not choose Delete, and the messages stay on the queue. They stay hidden for the queue's default visibility timeout. The results list shows each message's receive count.

With the AWS CLI

Receive up to 10 messages, hold them for 60 seconds, and save the response:

QUEUE_URL="https://sqs.us-east-1.amazonaws.com/123456789012/orders"

aws sqs receive-message \
  --queue-url "$QUEUE_URL" \
  --max-number-of-messages 10 \
  --visibility-timeout 60 \
  --message-system-attribute-names ApproximateReceiveCount SentTimestamp \
  --message-attribute-names All \
  --output json > peek.json

Read them:

jq '.Messages[]? | {MessageId, ReceiveCount: .Attributes.ApproximateReceiveCount, Body}' peek.json

Release them, so your consumers get them now and not in 60 seconds:

jq -r '.Messages[]?.ReceiptHandle' peek.json |
  while read -r handle; do
    aws sqs change-message-visibility \
      --queue-url "$QUEUE_URL" \
      --receipt-handle "$handle" \
      --visibility-timeout 0
  done

A single receive returns at most 10 messages, and a standard queue returns them in no fixed order. To look through more, see How to Search an SQS Queue for a Message.

With Tarmac

Tarmac is a desktop client for SQS on macOS and Windows. Tarmac Free cannot delete messages at all. It receives, reads, and releases.

  1. Select the queue.
  2. In the Operations panel, set Count and Visibility (min), then press Fetch Messages.
  3. Click a message to open the inspector. The Body tab shows formatted JSON. The System tab shows the receive count and sent time.

Every message you fetch stays in a local cache on your machine. Read it again tomorrow without another receive. When you quit, or clear the queue's cache, Tarmac releases every message it still holds.

To watch new messages arrive, use Live Tail. It holds each message for one second, and it stops itself when a message nears the queue's redrive limit. See Receive and Cache AWS SQS Messages.

Deleting is a Pro action, and it is always staged. Nothing is deleted until you review the batch and publish it.

On this page