Skip to main content
The Queue component lets you add a serverless queue to your app. It uses Amazon SQS.

Constructor

sst.config.ts
const queue = new sst.aws.Queue("MyQueue");

Parameters

fifo

fifo
boolean | object
default:"false"
Make this a FIFO (first-in-first-out) queue. FIFO queues guarantee messages are processed exactly once in order.
{
  fifo: true
}
Enable content-based deduplication:
{
  fifo: {
    contentBasedDeduplication: true
  }
}
Changing between standard and FIFO will destroy and recreate the queue.

visibilityTimeout

visibilityTimeout
duration
default:"30 seconds"
The time a message is invisible after being received. Between 0 seconds and 12 hours.
{
  visibilityTimeout: "1 hour"
}

dlq

dlq
string | object
Configure a dead-letter queue (DLQ) to store messages that can’t be processed.
const dlq = new sst.aws.Queue("MyDLQ");

new sst.aws.Queue("MyQueue", {
  dlq: dlq.arn
});
Customize retry count:
{
  dlq: {
    queue: dlq.arn,
    retry: 5
  }
}

Properties

url

arn

nodes

Methods

subscribe

SDK

Send messages to the queue from your function code:
src/api.ts
import { Resource } from "sst";
import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs";

const client = new SQSClient();

await client.send(new SendMessageCommand({
  QueueUrl: Resource.MyQueue.url,
  MessageBody: JSON.stringify({ hello: "world" })
}));

Examples

Create a FIFO queue

sst.config.ts
new sst.aws.Queue("MyQueue", {
  fifo: true
});

Add a subscriber

sst.config.ts
const queue = new sst.aws.Queue("MyQueue");
queue.subscribe("src/subscriber.handler");
sst.config.ts
const queue = new sst.aws.Queue("MyQueue");

new sst.aws.Function("MyFunction", {
  handler: "src/api.handler",
  link: [queue]
});

Add a dead-letter queue

sst.config.ts
const dlq = new sst.aws.Queue("MyDLQ");

new sst.aws.Queue("MyQueue", {
  dlq: {
    queue: dlq.arn,
    retry: 3
  }
});

Build docs developers (and LLMs) love