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

aws-sqs-xl-messages

v1.1.0

Published

This package is responsible for manage sqs messages bigger than 256KB

Downloads

505

Readme

AWS SQS XL Messages

Inspired by amazon-sqs-java-extended-client-lib

The AWS SQS XL Messages Library enables you to manage Amazon SQS message payloads with Amazon S3. This is especially useful for storing and retrieving messages with a message payload size greater than the current SQS limit of 256 KB, up to a maximum of 2 GB. Specifically, you can use this library to:

  • Specify whether message payloads are always stored in Amazon S3 or only when a message's size exceeds 256 KB.

  • Send a message that references a single message object stored in an Amazon S3 bucket.

  • Get the corresponding message object from an Amazon S3 bucket.

  • Delete the corresponding message object from an Amazon S3 bucket.

Overview

Architecture

Usage

  1. Add aws-sdk and aws-sqs-xl-messages to your dependencies:

    $ npm i aws-sdk aws-sqs-xl-messages
  2. Decorate an SQS client from aws-sdk with this library:

    const { SQS, S3 } = require("aws-sdk"),
        { SQSExt, Config } = require("aws-sqs-xl-messages")(SQS), // inject the SQS client that will be decorated
        config = new Config();
    
    config.enableLargePayloadSupport(new S3(), "my-bucket"); // tell the client which S3 bucket to use.
    
    // optionally tell the client whether it must always upload messages to S3. This defaults to false.
    config.alwaysThroughS3 = false;
    // optionally tell the client whether it must prefix S3 objects with the QueueName. Useful if you
    // plan to use one single bucket for more than one SQS queue. This defaults to true.
    config.addQueueToS3Key = true;
    
    let sqs = new SQSExt({ extendedConfig: config });
    
    // you can now use sqs as if it was an sqs client from aws-sdk
    
    // will send message's body to S3 if it's larger than the threshold (or alwaysThroughS3)
    await sqs.sendMessage(sendParams).promise();
    
    // will fetch transparently message's body from S3 when needed.
    const response = await sqs.receiveMessages(receiveParams).promise();
    
    // will delete S3 object (if any) too.
    await sqs.deleteMessage(deleteParams).promise();

Lambda integration

When working with AWS Lambda, you don't need to call receiveMessage and deleteMessage manually. It's managed internally by AWS. That means we can't transparently download nor delete S3 objects. It needs to be done manually inside the lambda function.

To solve this issue, two methods are exposed: transformLambdaRecords and deleteRecords. They take care of downloading messages from S3; and removing them from S3 respectively.

const { SQS, S3 } = require("aws-sdk"),
    { SQSExt, Config } = require("aws-sqs-xl-messages")(SQS); // inject the SQS client that will be decorated


// lambda handler
const handler = async (event, context) => {
    const config = new Config();

    config.enableLargePayloadSupport(new S3(), "my-bucket"); // tell the client which S3 bucket to use.

    const sqsClient = new SQSExt({ extendedConfig: config }),
        records = await sqsClient.transformLambdaRecords(event.Records);

    // Apply your lambda logic using records. message bodies are now the content from S3.

    await sqsClient.deleteRecords(records);
};

module.exports = handler;

Optionally, an S3 lifecycle can be set up to delete S3 objects older than a threshold. So you don't need to call deleteRecords directly.

Limitations

v1.1.0 has a few limitations:

  1. Only the following methods are decorated:

    • sendMessage

    • receiveMessage

    • deleteMessage

    • deleteMessageBatch


    NOTE

    We plan to extend this list at least with sendMessageBatch, purgeQueue and deleteQueue.


  2. Decoration is done by overwriting AWS.Request methods, and some workflows are not yet supported. In particular, promise-like and in-place callbacks will work. However calling to send manually won't.

    // this works
    await sqs.sendMessage(params).promise();
    
    // this works
    sqs.sendMessage(params, callback);
    
    // this doesn't work
    let request = sqs.sendMessage(params);
    request.send(callback);