$ aws sqs create-queue --queue-name my-test-queue --attributes ReceiveMessageWaitTimeSeconds=20
{
"QueueUrl": "https://ap-northeast-1.queue.amazonaws.com/000000000000/my-test-queue"
}
$ aws sqs list-queues
{
"QueueUrls": [
"https://ap-northeast-1.queue.amazonaws.com/000000000000/my-test-queue"
]
}
$ QUEUE_URL=$(aws sqs get-queue-url --queue-name my-test-queue | npx jqf --raw-string-output 'x => x.QueueUrl')
$ aws sqs send-message --queue-url $QUEUE_URL --message-body '{"hello":"SQS"}'
{
"MD5OfMessageBody": "23759ae80d00f2b3e9c5eb026b74fdd8",
"MessageId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
$ aws sqs receive-message --queue-url $QUEUE_URL
{
"Messages": [
{
"MessageId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"ReceiptHandle": "<base 64 value>",
"MD5OfBody": "23759ae80d00f2b3e9c5eb026b74fdd8",
"Body": "{\"hello\":\"SQS\"}"
}
]
}
$ aws sqs delete-message --receipt-handle "<base 64 value>" --queue-url $QUEUE_URL
# shell A
$ QUEUE_URL=$(aws sqs get-queue-url --queue-name my-test-queue | npx jqf --raw-string-output 'x => x.QueueUrl')
$ aws sqs receive-message --queue-url $QUEUE_URL
# shell B
QUEUE_URL=$(aws sqs get-queue-url --queue-name my-test-queue | npx jqf --raw-string-output 'x => x.QueueUrl')
$ aws sqs send-message --queue-url $QUEUE_URL --message-body '{"hello":"SQS"}'
$ aws sqs delete-queue --queue-url $QUEUE_URL