Skip to main content

Queue

Creates and manages Amazon SQS queues with support for both standard and FIFO queues. Handles queue creation, attribute configuration, and automatic cleanup of deleted queues.

Props

queueName
string
Name of the queue. For FIFO queues, the name must end with the .fifo suffix.Default: ${app}-${stage}-${id} (with .fifo suffix if fifo is true)
fifo
boolean
Whether this is a FIFO queue. If true, the queueName must end with .fifo suffix.
visibilityTimeout
number
The length of time (in seconds) that a message received from a queue will be invisible to other receiving components.Default: 30
messageRetentionPeriod
number
The length of time (in seconds) for which Amazon SQS retains a message.Default: 345600 (4 days)
maximumMessageSize
number
The limit of how many bytes a message can contain before Amazon SQS rejects it.Default: 262144 (256 KB)
delaySeconds
number
The time in seconds that the delivery of all messages in the queue will be delayed.Default: 0
receiveMessageWaitTimeSeconds
number
The length of time (in seconds) for which a ReceiveMessage action waits for a message to arrive.Default: 0
contentBasedDeduplication
boolean
Enables content-based deduplication for FIFO queues. Only applicable when fifo is true.
deduplicationScope
'messageGroup' | 'queue'
Specifies whether message deduplication occurs at the message group or queue level. Only applicable when fifo is true.
fifoThroughputLimit
'perQueue' | 'perMessageGroupId'
Specifies whether the FIFO queue throughput quota applies to the entire queue or per message group. Only applicable when fifo is true.
tags
Record<string, string>
Resource tags for the queue.

Output

arn
string
ARN of the queue.
queueName
string
Name of the Queue.
url
string
URL of the queue.

Examples

Standard queue with custom visibility timeout

import { Queue } from "alchemy/aws";

const standardQueue = await Queue("my-queue", {
  queueName: "my-queue",
  visibilityTimeout: 30,
  tags: {
    Environment: "production"
  }
});

FIFO queue with content-based deduplication

import { Queue } from "alchemy/aws";

const fifoQueue = await Queue("orders-queue", {
  queueName: "orders-queue.fifo",
  fifo: true,
  contentBasedDeduplication: true,
  visibilityTimeout: 30,
  tags: {
    Environment: "production"
  }
});

Queue with custom message retention and size

import { Queue } from "alchemy/aws";

const customQueue = await Queue("large-messages", {
  queueName: "large-messages",
  messageRetentionPeriod: 345600,  // 4 days
  maximumMessageSize: 262144,      // 256 KB
  visibilityTimeout: 60,
  delaySeconds: 5,
  receiveMessageWaitTimeSeconds: 20
});

Build docs developers (and LLMs) love