aws-lambda-sqs-consumer
v0.1.3
Published
## Overview
Downloads
6
Readme
lambda-sqs-consumer
Overview
An event source mapping compliant lambda consumer factory for Amazon Simple Queue Service (SQS). The consumer function processes messages by type
which is present as a JSON string inside the message body.
Example
Here's an example:
const { createSQSConsumer } = require("aws-lambda-sqs-consumer");
exports.handler = createSQSConsumer({
events: {
EVENT_TYPE_A: {
handler(message) {
console.log("Processing type a:", message.messageId);
},
},
EVENT_TYPE_B: {
handler(message) {
console.log("Processing type b:", message.messageId);
},
},
},
});
This would process messages of the type
EVENT_TYPE_A
and EVENT_TYPE_B
.
Here's a sample message body for EVENT_TYPE_A
:
{ "type": "EVENT_TYPE_A", "payload": { "someproperty": "somevalue" } }
Reference
The reference can be found here.