Testing launching a Lambda from AWS SQS and a naive Request-Response Messaging Pattern implementation.
This is not production code, it doesn't work with concurrency, there is currently no implementation for SQS Virtual Queues on AWS SDK JS. Check Request-Response Messaging Pattern (Virtual Queues)
- User sends a request to
jobSubmit
- It then published to
sqsTestTsQueue
- Worker listen to
sqsTestTsQueue
and process the job - Then publishing results to
sqsTestTsQueueResult
- User can periodically check for results using
jobResult
endpoint, which checkssqsTestTsQueueResult
for results.
sls create \
--template aws-nodejs-typescript \
--path sqs-test-ts \
--name sqs-test-ts
# Development packages
serverless plugin install --name serverless-iam-roles-per-function
serverless plugin install --name serverless-offline
serverless plugin install --name serverless-prune-plugin
npm i -D \
@types/aws-lambda \
@types/node
# Production packages
npm i \
aws-sdk \
aws-lambda
# Send Message
curl -XPOST -d@data/send-message.json \
https://5lusfu0ct5.execute-api.us-east-1.amazonaws.com/dev/sqs/jobSubmit
# Check for Response
curl https://5lusfu0ct5.execute-api.us-east-1.amazonaws.com/dev/sqs/jobResult