Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Work with Amazon SQS for reliable message queuing. Create standard and FIFO queues, configure dead-letter queues for failed messages, send and receive messages in batches, and build decoupled event-driven architectures.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 165% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 79% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 117% | 0% |
| case-12 | ✓→✓ | = Same ✓ | 323% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 169% | 0% |
Amazon Simple Queue Service (SQS) is a fully managed message queuing service for decoupling microservices. It offers two queue types: Standard (best-effort ordering, at-least-once delivery) and FIFO (exactly-once, ordered).
bash# Create a standard queue aws sqs create-queue \ --queue-name order-processing \ --attributes '{ "VisibilityTimeout": "60", "MessageRetentionPeriod": "1209600", "ReceiveMessageWaitTimeSeconds": "20" }'
bash# Create a FIFO queue (name must end in .fifo) aws sqs create-queue \ --queue-name order-processing.fifo \ --attributes '{ "FifoQueue": "true", "ContentBasedDeduplication": "true", "VisibilityTimeout": "60" }'
bash# Create the DLQ first aws sqs create-queue --queue-name order-processing-dlq # Get DLQ ARN DLQ_ARN=$(aws sqs get-queue-attributes \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing-dlq \ --attribute-names QueueArn --query 'Attributes.QueueArn' --output text) # Configure main queue to use DLQ after 3 failed attempts aws sqs set-queue-attributes \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing \ --attributes '{ "RedrivePolicy": "{\"deadLetterTargetArn\":\"'$DLQ_ARN'\",\"maxReceiveCount\":\"3\"}" }'
bash# Redrive messages from DLQ back to source queue aws sqs start-message-move-task \ --source-arn "$DLQ_ARN" \ --destination-arn "arn:aws:sqs:us-east-1:123456789:order-processing"
bash# Send a single message aws sqs send-message \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing \ --message-body '{"orderId":"12345","action":"process"}' \ --message-attributes '{ "OrderType": {"DataType":"String","StringValue":"premium"} }'
bash# Send to FIFO queue with group ID aws sqs send-message \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing.fifo \ --message-body '{"orderId":"12345","action":"process"}' \ --message-group-id "customer-789" \ --message-deduplication-id "order-12345-v1"
bash# Send up to 10 messages in a batch aws sqs send-message-batch \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing \ --entries '[ {"Id":"1","MessageBody":"{\"orderId\":\"001\"}"}, {"Id":"2","MessageBody":"{\"orderId\":\"002\"}"}, {"Id":"3","MessageBody":"{\"orderId\":\"003\"}"} ]'
python# Batch consumer with boto3 import boto3 import json sqs = boto3.client('sqs') QUEUE_URL = 'https://sqs.us-east-1.amazonaws.com/123456789/order-processing' def poll_and_process(): while True: response = sqs.receive_message( QueueUrl=QUEUE_URL, MaxNumberOfMessages=10, # batch up to 10 WaitTimeSeconds=20, # long polling MessageAttributeNames=['All'] ) messages = response.get('Messages', []) if not messages: continue entries_to_delete = [] for msg in messages: try: body = json.loads(msg['Body']) process_order(body) entries_to_delete.append({ 'Id': msg['MessageId'], 'ReceiptHandle': msg['ReceiptHandle'] }) except Exception as e: print(f"Failed: {e}") # Message returns to queue after visibility timeout if entries_to_delete: sqs.delete_message_batch( QueueUrl=QUEUE_URL, Entries=entries_to_delete )
bash# Receive messages with long polling aws sqs receive-message \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing \ --max-number-of-messages 5 \ --wait-time-seconds 20 \ --message-attribute-names All
bash# Delete a processed message aws sqs delete-message \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing \ --receipt-handle "AQEBzL..."
bash# Change visibility timeout for a message needing more processing time aws sqs change-message-visibility \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing \ --receipt-handle "AQEBzL..." \ --visibility-timeout 120
bash# Check queue depth aws sqs get-queue-attributes \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing \ --attribute-names ApproximateNumberOfMessages,ApproximateNumberOfMessagesNotVisible,ApproximateNumberOfMessagesDelayed
bash# Purge all messages (use with caution) aws sqs purge-queue \ --queue-url https://sqs.us-east-1.amazonaws.com/123456789/order-processing
ApproximateNumberOfMessages and alert on queue depth spikesOther measured skills in the registry, with their headline benchmark lift.