Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 2.29 KB

File metadata and controls

76 lines (57 loc) · 2.29 KB

Simple SQS Standard Example

This example demonstrates how to setup a SQS Standard and send messages through the message body and attributes.

The queue was created by using the queue construct from the Lift plugin.

Use Cases

  • Decouple message producers from message consumers.
  • This is one way to architect for scale and reliability.

Setup

npm install to install all needed packages.

Deployment

In order to deploy the service run:

sls deploy

for deploying with a specific profile (located in ~/.aws/credentials) you can simply use the command:

AWS_PROFILE=YOUR_PROFILE_NAME sls deploy

for deploying to the specific stage, let's say staging do:

sls deploy --stage staging

The expected result should be similar to:

✔ Service deployed to stack aws-node-typescript-sqs-standard-dev (345s)

endpoint: POST - https://XXXXXXXXX.execute-api.REGION.amazonaws.com/sender
functions:
  sender: aws-node-typescript-sqs-standard-STAGE-sender (8 MB)
   receiver: aws-node-typescript-sqs-standard-dev-receiver (8 MB)
  mySimpleQueueWorker: aws-node-typescript-sqs-standard-YOUR-STAGE-mySimpleQueueWorker (8 MB)
updateData: https://sqs.REGION.amazonaws.com/XXXXXXXXXXX/aws-node-typescript-sqs-standard-dev-mySimpleQueue

Usage

  • Send a HTTP POST request to the sender lambda with a JSON payload (The response will be {"message":"Message placed in the Queue!"})
  • To print out the logs of the receiver sqs handler on the terminal. sls logs -f mySimpleQueueWorker -t It will look like:
    serverless logs  -f mySimpleQueueWorker
    Running "serverless" from node_modules
    START
    2022-08-06 16:24:46.022 INFO    Message Attributtes -->   Attribute Value Here
    2022-08-06 16:24:46.023 INFO    Message Body -->   "test"
    END Duration: 2.83 ms (init: 155.47 ms) Memory Used: 56 MB
  • Alternatively you can check cloudwatch logs.