Loopback sqs consumer middleware
This is a simple middleware listening for Amazon Simple Queue Service events on a speficied queue.
INSTALL
npm install loopback-sqs-consumer-middleware --save
SERVER CONFIG
Add the middleware to your middleware.json:
HANDLER
You need to define an event handler (in the previous example config, sqsEventHandler.js) with the following structure in the loopback server directory.
'use strict'; moduleexports = { console; ; } { console; } { console; } { console; } { console; } { console; } { console; } { console; };
CONNEXIONS
To be able to connect to your SQS queue and listen for events in the topic, you have to set the SQS_QUEUE_URL env variable. You also have to set AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID for authentication.
export SQS_QUEUE_URL=https://sqs.eu-west-1.amazonaws.com/account-id/queue-nameexport AWS_SECRET_ACCESS_KEY=...export AWS_ACCESS_KEY_ID=...