Bootstrap FreeKB - Amazon Web Services (AWS) - Get Simple Queue Service (SQS) Messages using boto3
Amazon Web Services (AWS) - Get Simple Queue Service (SQS) Messages using boto3


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

If you are not familiar with AWS Simple Queue Service (SQS), check out my article Amazon Web Services (AWS) - Getting Started with Simple Queue Service (SQS).

The aws sqs list-queues command can be used to list your queues.

~]$ aws sqs list-queues
{
    "QueueUrls": [
        "https://queue.amazonaws.com/123456789012/my-first-queue"
    ]
}

 

Likewise, the aws sqs get-queue-url command can be used to get the URL of your queue.

~]$ aws sqs get-queue-url --queue-name my-first-queue
{
    "QueueUrl": "https://queue.amazonaws.com/123456789012/my-first-queue"
}

 

And then the aws sqs receive-message command can be used to get the message from the queue. The body is "hello".

 ~]$ aws sqs receive-message --queue-url https://queue.amazonaws.com/123456789012/my-first-queue
{
    "Messages": [
        {
            "Body": "hello",
            "ReceiptHandle": "AQEBqy3nHXKLjlXFCw7ZMky0z6bMgEG0MvvnNBLnQ/1drFX+9Oqh291bmiu3AqQjKni+REeYhyidtW5m+blD5WDA66dqfmGsk6q79jfrZf5GjNwgWU7FNJlm6//Sw21HdezqygzlM4slAQ54URQ9CqaTTUSmjWK6rwPuXrG1ULswGdUzp2ZNtxvSUy1km+nLy7Yp9rGhwUAX3vJlAZAGKKvce6owT/Tnf/uSi68dpv91mJH6LR23QUOdnBk8Bgl1v1SF1QkIo+DiMhY3/IoSu9FpnCZj3rSbafY32FcTLmqfctuVGAJnU9mkNRQuCMATFoSVkkjAgOrKjUZaQMZ6eyNdIS+l67N2QNbUpgsBBQtLaGg8CBHIkGCGJkKV+/ekgUXWj6/godVCkgOwo/hEeZeegQ==",
            "MD5OfBody": "5d41402abc4b2a76b9719d911017c592",
            "MessageId": "5508026b-e650-45d8-8482-8d13623d6a6b"
        }
    ]
}



Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 5ff88d in the box below so that we can be sure you are a human.