MildStack Logo

Amazon SQS

MildStack provides SQS emulation with standard and FIFO queues, dead-letter queues, message move tasks, and full message lifecycle support.

Overview

MildStack's SQS emulation lets you create queues, send and receive messages, and configure dead-letter queues locally. It supports both standard and FIFO queues, and is fully compatible with the AWS SQS API.

Supported Operations

Queue Lifecycle

OperationDescription
CreateQueueCreate a new standard or FIFO queue
DeleteQueueDelete a queue and all its messages
GetQueueUrlGet the URL of a queue by name
ListQueuesList all queues
PurgeQueueDelete all messages in a queue
GetQueueAttributesGet queue configuration (visibility timeout, DLQ, etc.)
SetQueueAttributesUpdate queue configuration

Message Operations

OperationDescription
SendMessageSend a single message to a queue
SendMessageBatchSend up to 10 messages in a single request
ReceiveMessageReceive one or more messages from a queue
DeleteMessageDelete a processed message
DeleteMessageBatchDelete multiple messages at once
ChangeMessageVisibilityExtend or shorten the visibility timeout of a message
ChangeMessageVisibilityBatchUpdate visibility for multiple messages

Queue Tags & Permissions

OperationDescription
TagQueueAdd tags to a queue
UntagQueueRemove tags from a queue
ListQueueTagsList all tags on a queue
AddPermissionAdd a permission to a queue policy
RemovePermissionRemove a permission from a queue policy

Dead-Letter Queue (DLQ) & Redrive

OperationDescription
ListDeadLetterSourceQueuesList queues that use a specific DLQ
StartMessageMoveTaskStart moving messages from a DLQ back to the source queue
CancelMessageMoveTaskCancel a running message move task
ListMessageMoveTasksList active and completed move tasks

Quick Example

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

const sqs = new SQSClient({
  region: "us-east-1",
  endpoint: "http://localhost:4566",
  credentials: { accessKeyId: "test", secretAccessKey: "test" },
});

// Create a queue
const { QueueUrl } = await sqs.send(
  new CreateQueueCommand({ QueueName: "tasks" })
);

// Send a message
await sqs.send(
  new SendMessageCommand({
    QueueUrl,
    MessageBody: JSON.stringify({
      action: "process-image",
      imageId: "img-456",
    }),
  })
);

// Receive messages
const { Messages } = await sqs.send(
  new ReceiveMessageCommand({
    QueueUrl,
    MaxNumberOfMessages: 10,
    WaitTimeSeconds: 5,
  })
);

// Process and delete
if (Messages) {
  for (const message of Messages) {
    console.log("Received:", message.Body);
    await sqs.send(
      new DeleteMessageCommand({
        QueueUrl,
        ReceiptHandle: message.ReceiptHandle,
      })
    );
  }
}

Dead-Letter Queue Example

Configure a DLQ to capture messages that fail processing:

// Create the DLQ
const { QueueUrl: dlqUrl } = await sqs.send(
  new CreateQueueCommand({ QueueName: "tasks-dlq" })
);

// Get the DLQ ARN
const { Attributes } = await sqs.send(
  new GetQueueAttributesCommand({
    QueueUrl: dlqUrl,
    AttributeNames: ["QueueArn"],
  })
);

// Create the main queue with redrive policy
await sqs.send(
  new CreateQueueCommand({
    QueueName: "tasks",
    Attributes: {
      RedrivePolicy: JSON.stringify({
        deadLetterTargetArn: Attributes.QueueArn,
        maxReceiveCount: "3",
      }),
    },
  })
);

After a message has been received 3 times without being deleted, it's automatically moved to the DLQ.

FIFO Queue Example

FIFO queues guarantee ordered, exactly-once delivery:

# Create a FIFO queue
awslocal sqs create-queue \
  --queue-name orders.fifo \
  --attributes FifoQueue=true,ContentBasedDeduplication=true

# Send a message with a group ID
awslocal sqs send-message \
  --queue-url http://localhost:4566/000000000000/orders.fifo \
  --message-body '{"orderId": "order-789"}' \
  --message-group-id "customer-123"

FIFO queue names must end with .fifo. Messages within the same message group are delivered in order.

Queue URL Format

MildStack uses the following URL format for queues:

http://localhost:4566/000000000000/<queue-name>

The account ID 000000000000 is a default placeholder used for local development.

Persistence

All SQS data (queues, messages, DLQ configuration) is stored locally and persists across instance restarts. Deleting an instance removes all its SQS data.

On this page