@driimus/sqs-permanent-failure-dlq
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

@driimus/sqs-permanent-failure-dlq

npm

Non-retryable error handler for @driimus/lambda-batch-processor that sends corresponding SQS messages to a dead-letter SQS queue.

Installation

[!WARNING] This is an ES only package. Before installing, make sure that your project's configuration supports ECMAScript modules.

pnpm add @driimus/lambda-batch-processor @driimus/sqs-permanent-failure-dlq @aws-sdk/client-sqs

Type hints

For types to work as expected, @types/aws-lambda must be installed:

pnpm add --save-dev @types/aws-lambda

Usage

import { SQSBatchProcessor } from '@driimus/lambda-batch-processor';
import { PermanentFailureDLQHandler } from '@driimus/sqs-permanent-failure-dlq';

const queueUrl = 'https://queue.amazonaws.com/80398EXAMPLE/MyQueue'; // your queue url

const processor = new SQSBatchProcessor(
  async (record) => {
    /** do stuff */
  },
  {
    nonRetryableErrorHandler: new PermanentFailureDLQHandler(queueUrl),
  },
);

export const handler = processor.process;

Custom SQS Client

By default, every instance of the handler will instantiate a new SQS client. It is possible to provide a custom client, which is especially helpful in scenarios where additional instrumentation is required, or you need to reuse the client elsewhere.

import { SQSClient } from '@aws-sdk/client-sqs';
import { PermanentFailureDLQHandler } from '@driimus/sqs-permanent-failure-dlq';

const sqs = new SQSClient({
  /** custom config */
});

const queueUrl = 'https://queue.amazonaws.com/80398EXAMPLE/MyQueue'; // your queue url

const nonRetryableErrorHandler = new PermanentFailureDLQHandler(queueUrl, sqs);

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i @driimus/sqs-permanent-failure-dlq

    Weekly Downloads

    12

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    8.24 kB

    Total Files

    7

    Last publish

    Collaborators

    • driimus