or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

batch-operations.mdclient-configuration.mddead-letter-queues.mdindex.mdmessage-move-tasks.mdmessage-operations.mdqueue-attributes-tags.mdqueue-management.mdqueue-permissions.md
tile.json

queue-management.mddocs/

Queue Management

Complete queue lifecycle operations including creation, deletion, attribute management, URL resolution, and queue listing.

Capabilities

Create Queue

Creates a new SQS queue with optional attributes and tags.

class CreateQueueCommand {
  constructor(input: CreateQueueCommandInput);
}

interface CreateQueueCommandInput {
  /** Name of the queue to create (up to 80 characters) */
  QueueName: string;
  /** Queue configuration attributes */
  Attributes?: Record<QueueAttributeName, string>;
  /** Tags to apply to the queue */
  tags?: Record<string, string>;
}

interface CreateQueueCommandOutput {
  /** URL of the created queue */
  QueueUrl?: string;
}

Usage Examples:

import { SQSClient, CreateQueueCommand } from "@aws-sdk/client-sqs";

const client = new SQSClient({ region: "us-east-1" });

// Create basic queue
const basicQueue = await client.send(new CreateQueueCommand({
  QueueName: "MyBasicQueue"
}));

// Create FIFO queue with attributes
const fifoQueue = await client.send(new CreateQueueCommand({
  QueueName: "MyFifoQueue.fifo",
  Attributes: {
    FifoQueue: "true",
    ContentBasedDeduplication: "true",
    MessageRetentionPeriod: "1209600", // 14 days
    VisibilityTimeoutSeconds: "30"
  },
  tags: {
    Environment: "production",
    Application: "myapp"
  }
}));

// Create queue with dead letter queue
const dlqQueue = await client.send(new CreateQueueCommand({
  QueueName: "MyQueueWithDLQ",
  Attributes: {
    RedrivePolicy: JSON.stringify({
      deadLetterTargetArn: "arn:aws:sqs:us-east-1:123456789012:MyDeadLetterQueue",
      maxReceiveCount: 3
    })
  }
}));

Delete Queue

Deletes an existing SQS queue and all messages in it.

class DeleteQueueCommand {
  constructor(input: DeleteQueueCommandInput);
}

interface DeleteQueueCommandInput {
  /** URL of the queue to delete */
  QueueUrl: string;
}

Usage Examples:

// Delete queue
await client.send(new DeleteQueueCommand({
  QueueUrl: "https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue"
}));

List Queues

Retrieves a list of queue URLs, optionally filtered by queue name prefix.

class ListQueuesCommand {
  constructor(input?: ListQueuesCommandInput);
}

interface ListQueuesCommandInput {
  /** Queue name prefix for filtering results */
  QueueNamePrefix?: string;
  /** Token for pagination */
  NextToken?: string;
  /** Maximum number of results to return */
  MaxResults?: number;
}

interface ListQueuesCommandOutput {
  /** Array of queue URLs */
  QueueUrls?: string[];
  /** Token for next page of results */
  NextToken?: string;
}

Usage Examples:

// List all queues
const allQueues = await client.send(new ListQueuesCommand());
console.log("All queues:", allQueues.QueueUrls);

// List queues with prefix
const prefixedQueues = await client.send(new ListQueuesCommand({
  QueueNamePrefix: "MyApp"
}));

// Paginated listing
let nextToken: string | undefined;
do {
  const result = await client.send(new ListQueuesCommand({
    MaxResults: 10,
    NextToken: nextToken
  }));
  
  console.log("Batch:", result.QueueUrls);
  nextToken = result.NextToken;
} while (nextToken);

Get Queue URL

Retrieves the URL for a queue by name, optionally specifying the queue owner.

class GetQueueUrlCommand {
  constructor(input: GetQueueUrlCommandInput);
}

interface GetQueueUrlCommandInput {
  /** Name of the queue */
  QueueName: string;
  /** AWS account ID of the queue owner */
  QueueOwnerAWSAccountId?: string;
}

interface GetQueueUrlCommandOutput {
  /** URL of the queue */
  QueueUrl?: string;
}

Usage Examples:

// Get URL for own queue
const ownQueue = await client.send(new GetQueueUrlCommand({
  QueueName: "MyQueue"
}));

// Get URL for cross-account queue
const crossAccountQueue = await client.send(new GetQueueUrlCommand({
  QueueName: "SharedQueue",
  QueueOwnerAWSAccountId: "123456789012"
}));

Get Queue Attributes

Retrieves queue configuration attributes.

class GetQueueAttributesCommand {
  constructor(input: GetQueueAttributesCommandInput);
}

interface GetQueueAttributesCommandInput {
  /** URL of the queue */
  QueueUrl: string;
  /** List of attribute names to retrieve (use 'All' for all attributes) */
  AttributeNames?: QueueAttributeName[];
}

interface GetQueueAttributesCommandOutput {
  /** Map of attribute names to values */
  Attributes?: Record<QueueAttributeName, string>;
}

Usage Examples:

// Get all attributes
const allAttributes = await client.send(new GetQueueAttributesCommand({
  QueueUrl: "https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue",
  AttributeNames: ["All"]
}));

// Get specific attributes
const specificAttributes = await client.send(new GetQueueAttributesCommand({
  QueueUrl: "https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue",
  AttributeNames: [
    "ApproximateNumberOfMessages",
    "ApproximateNumberOfMessagesNotVisible",
    "VisibilityTimeoutSeconds"
  ]
}));

console.log("Messages in queue:", specificAttributes.Attributes?.ApproximateNumberOfMessages);
console.log("Messages in flight:", specificAttributes.Attributes?.ApproximateNumberOfMessagesNotVisible);

Set Queue Attributes

Modifies queue configuration attributes.

class SetQueueAttributesCommand {
  constructor(input: SetQueueAttributesCommandInput);
}

interface SetQueueAttributesCommandInput {
  /** URL of the queue */
  QueueUrl: string;
  /** Map of attributes to set */
  Attributes: Record<QueueAttributeName, string>;
}

Usage Examples:

// Update visibility timeout and message retention
await client.send(new SetQueueAttributesCommand({
  QueueUrl: "https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue",
  Attributes: {
    VisibilityTimeoutSeconds: "60",
    MessageRetentionPeriod: "604800" // 7 days
  }
}));

// Configure dead letter queue
await client.send(new SetQueueAttributesCommand({
  QueueUrl: "https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue",
  Attributes: {
    RedrivePolicy: JSON.stringify({
      deadLetterTargetArn: "arn:aws:sqs:us-east-1:123456789012:MyDLQ",
      maxReceiveCount: 5
    })
  }
}));

Purge Queue

Removes all messages from a queue without deleting the queue itself.

class PurgeQueueCommand {
  constructor(input: PurgeQueueCommandInput);
}

interface PurgeQueueCommandInput {
  /** URL of the queue to purge */
  QueueUrl: string;
}

Usage Examples:

// Clear all messages from queue
await client.send(new PurgeQueueCommand({
  QueueUrl: "https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue"
}));

console.log("All messages removed from queue");

Queue Attribute Names

Available queue attributes for configuration and retrieval:

enum QueueAttributeName {
  All = "All",
  Policy = "Policy",
  VisibilityTimeoutSeconds = "VisibilityTimeoutSeconds",
  MaxReceiveCount = "MaxReceiveCount", 
  MessageRetentionPeriod = "MessageRetentionPeriod",
  ApproximateNumberOfMessages = "ApproximateNumberOfMessages",
  ApproximateNumberOfMessagesNotVisible = "ApproximateNumberOfMessagesNotVisible",
  CreatedTimestamp = "CreatedTimestamp",
  LastModifiedTimestamp = "LastModifiedTimestamp",
  QueueArn = "QueueArn",
  ApproximateNumberOfMessagesDelayed = "ApproximateNumberOfMessagesDelayed",
  DelaySeconds = "DelaySeconds",
  ReceiveMessageWaitTimeSeconds = "ReceiveMessageWaitTimeSeconds",
  RedrivePolicy = "RedrivePolicy",
  FifoQueue = "FifoQueue",
  ContentBasedDeduplication = "ContentBasedDeduplication",
  KmsMasterKeyId = "KmsMasterKeyId",
  KmsDataKeyReusePeriodSeconds = "KmsDataKeyReusePeriodSeconds",
  DeduplicationScope = "DeduplicationScope",
  FifoThroughputLimit = "FifoThroughputLimit",
  RedriveAllowPolicy = "RedriveAllowPolicy",
  SqsManagedSseEnabled = "SqsManagedSseEnabled"
}

Error Handling

Common exceptions for queue management operations:

  • QueueDoesNotExist: Queue URL is incorrect or queue has been deleted
  • QueueDeletedRecently: Queue name was recently deleted and is not yet available for reuse
  • QueueNameExists: Queue name already exists in this region
  • InvalidAttributeName: Unsupported or invalid attribute name
  • InvalidAttributeValue: Invalid value for the specified attribute
  • PurgeQueueInProgress: Cannot purge queue while another purge is in progress
try {
  await client.send(new CreateQueueCommand({ QueueName: "ExistingQueue" }));
} catch (error) {
  if (error.name === 'QueueNameExists') {
    console.log("Queue already exists, getting URL instead");
    const result = await client.send(new GetQueueUrlCommand({ 
      QueueName: "ExistingQueue" 
    }));
    console.log("Queue URL:", result.QueueUrl);
  }
}