aws-lambda-sqs-consumer

0.1.3 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i aws-lambda-sqs-consumer

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

14.2 kB

Total Files

15

Last publish

Collaborators

  • hadichahine