npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@outbox-event-bus/sqs-publisher

v2.0.3

Published

![npm version](https://img.shields.io/npm/v/@outbox-event-bus/sqs-publisher?style=flat-square&color=2563eb) ![license](https://img.shields.io/npm/l/@outbox-event-bus/sqs-publisher?style=flat-square&color=2563eb)

Readme

SQS Publisher

npm version license

Reliable Point-to-Point Event Delivery

AWS SQS publisher for outbox-event-bus. Forwards events to SQS queues for reliable, asynchronous processing by backend workers.

import { SQSClient } from '@aws-sdk/client-sqs';
import { SQSPublisher } from '@outbox-event-bus/sqs-publisher';

const publisher = new SQSPublisher(bus, {
  sqsClient: new SQSClient({}),
  queueUrl: 'https://sqs.us-east-1.amazonaws.com/12345/my-queue'
});

publisher.subscribe(['user.created']);

When to Use

Choose SQS Publisher when:

  • You need a reliable buffer between your event bus and worker services.
  • You want managed scalability with no infrastructure to maintain.
  • You require delayed processing (via SQS visibility timeouts).
  • You need Dead Letter Queues (DLQ) for failed message handling.

Consider alternatives when:

  • You need pub/sub fan-out to multiple subscribers (use SNS instead).
  • You require complex event routing (use EventBridge).
  • You need global ordered logs (use Kafka).

Installation

npm install @outbox-event-bus/sqs-publisher

Configuration

SQSPublisherConfig

interface SQSPublisherConfig {
  sqsClient: SQSClient;           // AWS SDK v3 SQS client
  queueUrl: string;               // Target SQS Queue URL
  processingConfig?: {
    bufferSize?: number;          // Default: 50
    bufferTimeoutMs?: number;     // Default: 100
    concurrency?: number;         // Default: 5
  };
  retryConfig?: {
    maxAttempts?: number;         // Default: 3
    initialDelayMs?: number;      // Default: 1000
    maxDelayMs?: number;          // Default: 10000
  };
}

Configuration Options

  • sqsClient: An instance of the AWS SDK SQSClient.
  • queueUrl: The URL of the SQS queue.
  • processingConfig: (Optional) Settings for accumulation and batching.
    • bufferSize: Number of events to accumulate in memory before publishing. Default: 50.
    • bufferTimeoutMs: Maximum time to wait for a buffer to fill before flushing. Default: 100ms.
    • concurrency: Maximum number of concurrent batch requests to SQS. Default: 5.
  • retryConfig: (Optional) Custom retry settings for publishing failures.
    • maxAttempts: Maximum number of publication attempts. Default: 3.
    • initialDelayMs: Initial backoff delay in milliseconds. Default: 1000ms.
    • maxDelayMs: Maximum backoff delay in milliseconds. Default: 10000ms.

[!NOTE] The maxBatchSize for SQS is fixed at 10, as per AWS limits. If your bufferSize exceeds 10, the publisher will automatically split the buffer into multiple SQS batch requests. FIFO support is automatically enabled if the queueUrl ends in .fifo.

Batching & Buffering

This publisher has buffering enabled by default (50 items or 100ms).

  • Efficient Accumulation: Events are collected in memory until bufferSize is reached or bufferTimeoutMs expires.
  • Automatic SQS Batching: The publisher automatically chunks the buffered events into batches of 10 to respect SQS SendMessageBatch limits.

To disable buffering (process events one by one), set bufferSize to 1:

const publisher = new SQSPublisher(bus, {
  // ...
  processingConfig: { bufferSize: 1 }
});

Usage

Basic Setup

import { SQSClient } from '@aws-sdk/client-sqs';
import { SQSPublisher } from '@outbox-event-bus/sqs-publisher';

const publisher = new SQSPublisher(bus, {
  sqsClient: new SQSClient({ region: 'us-east-1' }),
  queueUrl: process.env.QUEUE_URL!
});

publisher.subscribe(['*']);

FIFO Queues

The publisher supports FIFO queues. It uses the event.id as the Deduplication ID and the event.type as the Message Group ID to ensure ordered processing within event types.

Message Format

Messages are published to SQS with:

| SQS Field | Value | Description | |-----------|-------|-------------| | Body | JSON.stringify(event) | The full event object. | | MessageAttributes | EventType | Set to the event type string. | | MessageGroupId | event.type | (FIFO only) Ensures ordering within type. | | DeduplicationId | event.id | (FIFO only) Prevents duplicates. |

Error Handling

SDK Retries

The AWS SDK handles transient errors automatically.

Application-Level Retries

Configure application-level retries for extra resiliency:

const publisher = new SQSPublisher(bus, {
  // ...
  retryConfig: {
    maxAttempts: 3,
    initialDelayMs: 1000
  }
});

Troubleshooting

Messages stuck in DLQ

  • Cause: Consumer failing. Check your worker logs.
  • Cause: Payload too large (> 256KB). Reduce payload size or store in S3.

Permissions

  • Cause: Ensure the IAM role has sqs:SendMessage on the specific queue resource.

License

MIT © Dunika