API mocks

On this page

SQS-compatible queues

A mock of Amazon SQS's AWS JSON protocol, as AWS SDK v3 speaks it: queues, sending, receiving with visibility timeouts, and batch deletes, with real Signature Version 4 authentication. Use it as the queue a producer writes to and a worker drains. Testlie is not affiliated with Amazon Web Services.

Connect

Create an SQS-compatible queues system under No-code. Requests are POST <base URL>/ with:

  • X-Amz-Target: AmazonSQS.<Operation>;
  • Content-Type: application/x-amz-json-1.0;
  • a JSON body;
  • a SigV4 signature (service sqs) with the system's access key.

Queue URLs are <base URL>/<account id>/<queue name>. The system's queue (SQS_QUEUE_NAME) exists from the start.

Give the client the base URL as its endpoint, in code or as AWS_ENDPOINT_URL_SQS; both are tested with @aws-sdk/client-sqs. Without one, AWS SDK v3 sends every call to the queue URL's origin only, which drops the mock's path:

js
const sqs = new SQSClient({ endpoint: "<base URL>", region: "us-east-1" });
// or: AWS_ENDPOINT_URL_SQS=<base URL>, and new SQSClient({ region: "us-east-1" })
Credential Environment variable
Access key id, secret access key AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
Region AWS_REGION (us-east-1)
Account id The queue URL's account segment
Queue name SQS_QUEUE_NAME

Operations

Queues CreateQueue (idempotent for the same attributes; QueueNameExists otherwise), GetQueueUrl, ListQueues, GetQueueAttributes, SetQueueAttributes, PurgeQueue
Sending SendMessage, SendMessageBatch (up to 10), with MessageAttributes and DelaySeconds
Receiving ReceiveMessage: MaxNumberOfMessages 1 to 10, VisibilityTimeout, WaitTimeSeconds, AttributeNames / MessageSystemAttributeNames, MessageAttributeNames (All, names, prefix.*)
Acknowledging DeleteMessage, DeleteMessageBatch, ChangeMessageVisibility, ChangeMessageVisibilityBatch. Each batch entry answers in Successful or Failed, e.g. ReceiptHandleIsInvalid for a stale handle.

Semantics:

  • A received message is invisible for its visibility timeout (the queue's 30 seconds by default), then comes back with ApproximateReceiveCount raised.
  • Changing the visibility to 0 hands it back at once.
  • Receipt handles are per receive: an older handle no longer deletes the message.
  • Two concurrent receivers never get the same message.
  • Receives are first-in first-out as far as possible; standard SQS promises no order.
  • WaitTimeSeconds long-polls for up to 5 seconds here, not 20.

Checksums: MD5OfMessageBody and MD5OfMessageAttributes are computed as SQS does, so SDK checksum validation passes.

Errors: AWS JSON errors, e.g. { "__type": "com.amazonaws.sqs#QueueDoesNotExist", "message": "…" }, with x-amzn-query-error: AWS.SimpleQueueService.NonExistentQueue;Sender.

Limits

These limits apply:

  • 10 queues and 1,000 messages per mock;
  • 256 KB per message.

Not implemented:

  • FIFO deduplication and ordering guarantees (a MessageGroupId is stored and returned);
  • dead-letter redrive;
  • tags;
  • the older XML Query protocol.