Documentation Index
Fetch the complete documentation index at: https://mintlify.com/anomalyco/sst/llms.txt
Use this file to discover all available pages before exploring further.
The Queue component lets you add a serverless queue to your app. It uses Amazon SQS.
Constructor
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.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
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:
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
new sst.aws.Queue("MyQueue", {
fifo: true
});
Add a subscriber
const queue = new sst.aws.Queue("MyQueue");
queue.subscribe("src/subscriber.handler");
Link to a function
const queue = new sst.aws.Queue("MyQueue");
new sst.aws.Function("MyFunction", {
handler: "src/api.handler",
link: [queue]
});
Add a dead-letter queue
const dlq = new sst.aws.Queue("MyDLQ");
new sst.aws.Queue("MyQueue", {
dlq: {
queue: dlq.arn,
retry: 3
}
});