How to peek at messages in the queue
Asked Answered
E

5

72

I don't want the message to count as "read" but I'd like to know what's in the queue. The documentation:

http://boto.s3.amazonaws.com/ref/sqs.html#module-boto.sqs

Isn't very straight forward about what absorbs a message and what doesn't. The dump message seems close, but I'd rather do this in memory rather than to a file.

The faq:

http://aws.amazon.com/articles/1343#12

Has some sketchy solution:

How do I peek at a message?

With version 2008-01-01, the PeekMessage action has been removed from Amazon SQS. This functionality was used mainly to debug small systems — specifically to confirm a message was successfully sent to the queue or deleted from the queue. To do this with version 2008-01-01, you can log the message ID and the receipt handle for your messages and correlate them to confirm when a message has been received and deleted.

Has anyone had any luck with this? It seems like very basic queue functionality and I'd be shocked if there wasn't a clean way to do this.

Expendable answered 11/4, 2012 at 5:48 Comment(0)
M
24

There is no longer a true peek function available in SQS but you can probably accomplish what you want by simply using get_messages and setting the visibility_timeout quite low. As long as you don't delete the messages you have read, they will reappear on the queue after the visibility_timeout has expired and will be available for reading. The only tricky part is trying to figure out how long the timeout should be. If you have lots and lots of messages in the queue, you will have to make multiple calls to get_messages to retrieve them all and you probably don't want previously read messages reappearing while you are still peeking at the messages.

Mousetrap answered 11/4, 2012 at 12:7 Comment(2)
One important consideration for this approach is if the queue has a "Redrive Policy", such as "If this message gets received 5 times and never deleted then put it into a separate dead-letter queue." In that scenario, your "peeks" will increment the receive count for the message and can lead to the message getting "failed" before it ever has a chance to truly get processed.Altonaltona
If all else fails, to avoid the 'redrive policy' you could read them, delete them and repost them... not great, but...Levy
V
109

Right click no longer works in the new SQS console.

To view queue messages in the SQS console you now need to click into a queue > Send and receive messages > Poll for messages

Verify answered 20/10, 2020 at 10:49 Comment(0)
M
24

There is no longer a true peek function available in SQS but you can probably accomplish what you want by simply using get_messages and setting the visibility_timeout quite low. As long as you don't delete the messages you have read, they will reappear on the queue after the visibility_timeout has expired and will be available for reading. The only tricky part is trying to figure out how long the timeout should be. If you have lots and lots of messages in the queue, you will have to make multiple calls to get_messages to retrieve them all and you probably don't want previously read messages reappearing while you are still peeking at the messages.

Mousetrap answered 11/4, 2012 at 12:7 Comment(2)
One important consideration for this approach is if the queue has a "Redrive Policy", such as "If this message gets received 5 times and never deleted then put it into a separate dead-letter queue." In that scenario, your "peeks" will increment the receive count for the message and can lead to the message getting "failed" before it ever has a chance to truly get processed.Altonaltona
If all else fails, to avoid the 'redrive policy' you could read them, delete them and repost them... not great, but...Levy
G
10

Update 11/11/2020

Right-clicking no longer works on new SQS console.

See @marmor's answer


Original Answer (old dashboard)

If you have access to Amazon's AWS Console, on the queue list page, you can right-click on a queue.

Then select View/Delete Messages from the pop-up menu.

This will pop-up a window where you can start polling for messages in the queue.

Refer to images below:

amazon sqs poll for messages

polling message pop-up window

Gavette answered 27/12, 2018 at 18:19 Comment(0)
D
2
  1. Open your AWS Console Queue.
  2. Click on "SEND AND RECEIVE MESSAGES."
  3. Navigate to the "Receive Messages" section. In the Messages list, locate the "Poll for messages" button and click on it.
  4. Find the ID of the message from the listed messages and click on it.
  5. You should now be able to view the content of the message.

send receive messages button poll messages button listed message after poll is clicked message content

Dashing answered 17/4 at 13:33 Comment(0)
U
-2

In the new AWS Console:

  • Visit the main queue page at https://console.aws.amazon.com/sqs
  • Click on the name of your queue - this will take you to its details page
  • Click on the "Send and Receive Messages" button (top right)
  • Click on the "Poll for Messages" button
  • Click on the message id to view message details
Unman answered 17/9, 2022 at 22:45 Comment(1)
This way the message is gonna be counted as read and the question wants to avoid this.Burgos

© 2022 - 2024 — McMap. All rights reserved.