Giter VIP home page Giter VIP logo

sandbox-amazon-sqs's Introduction

My Amazon SQS samples

Create queue

$ aws sqs create-queue --queue-name my-test-queue --attributes ReceiveMessageWaitTimeSeconds=20
{
    "QueueUrl": "https://ap-northeast-1.queue.amazonaws.com/000000000000/my-test-queue"
}

List queues

$ aws sqs list-queues
{
    "QueueUrls": [
        "https://ap-northeast-1.queue.amazonaws.com/000000000000/my-test-queue"
    ]
}

Get queue URL

$ QUEUE_URL=$(aws sqs get-queue-url --queue-name my-test-queue |  npx jqf --raw-string-output 'x => x.QueueUrl')

Send message

$ aws sqs send-message --queue-url $QUEUE_URL --message-body '{"hello":"SQS"}'
{
    "MD5OfMessageBody": "23759ae80d00f2b3e9c5eb026b74fdd8",
    "MessageId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

Receive message

$ aws sqs receive-message --queue-url $QUEUE_URL
{
    "Messages": [
        {
            "MessageId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "ReceiptHandle": "<base 64 value>",
            "MD5OfBody": "23759ae80d00f2b3e9c5eb026b74fdd8",
            "Body": "{\"hello\":\"SQS\"}"
        }
    ]
}

Delete message

$ aws sqs delete-message --receipt-handle "<base 64 value>" --queue-url $QUEUE_URL

Receive message when polling

# 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"}'

Delete queue

$ aws sqs delete-queue --queue-url $QUEUE_URL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.