Queue Demo

Demo: Create an Amazon SQS Queue

As noted in The AWS Blog by Jeff Barr in 2009, the Amazon Simple Queue Service (SQS) was the first AWS service released.

This queue demo could be demonstrated in (at least) two ways:

  • from scratch
  • from the awsdemo repo

The former includes examples of AWS CLI commands for sending and receiving messages. The latter includes examples of using Python code and the boto3 AWS SDK for Python to send and receive messages.

From Scratch

From the awsdemo repo

Purpose

Here are the purpose points for the queue demo deck.

  • Why? I want to use a message queue in the AWS cloud.
  • What? Use an AWS CDK environment.
  • Where? In my AWS account.
  • How? Use AWS CDK to create an Amazon SQS Queue.
  • Then… I can send and receive messages via a message queue in my AWS account.

Purpose: Create a CDK stack with a queue

Steps:

Create a CDK app (cdk init).
Uncomment the Amazon SQS bits (vi lib/queue-stack.ts).
Deploy the CDK app (cdk deploy).
Send and receive queue messages.
Remove the CDK app (cdk destroy).


Deploy a queue via CDK app stack

mkdir queue
cd queue
cdk init app --language=typescript
cdk deploy
aws sqs list-queues 
q=$(aws sqs list-queues --query "QueueUrls[0]" --output text)
aws sqs receive-message --queue-url $q --wait-time-seconds 20
aws sqs send-message --queue-url $q --message-body "hello, world" 
cdk destroy --force

Amazon SQS Documentation

Queue code examples:

Deploy a queue via CDK app stack with Python clients

git clone https://github.com/bwer432/awsdemo
cd awsdemo/queue-demo/queue
npm install # repopulate node_modules
npx cdk deploy
aws sqs list-queues 
q=$(aws sqs list-queues --query QueueUrls --output text | grep QueueStack-QueueQueue)
aws sqs receive-message --queue-url $q --wait-time-seconds 20
aws sqs send-message --queue-url $q --message-body "hello, world" 
python3 ../sqs-send.py $q
python3 ../sqs-recv.py $q
npx cdk destroy --force