Part 3 · 1 chapters · ~8 min
RabbitMQ and SQS
RabbitMQ exchanges, queues, bindings and routing keys, acknowledgements and prefetch, quorum queues, delayed messages and TTLs, SQS standard and FIFO queues, visibility timeouts and long polling, redrive policies, SNS fan-out, and choosing between RabbitMQ, SQS, Kafka and Redis-backed queues.
5
Two brokers
code
# RabbitMQ: topic exchange routing transfer events by country and type
channel.assertExchange('transfers', 'topic', { durable: true });
channel.assertQueue('receipts', { durable: true, arguments: { 'x-queue-type': 'quorum', 'x-dead-letter-exchange': 'dlx' } });
channel.bindQueue('receipts', 'transfers', 'transfer.completed.*');
channel.prefetch(20);
channel.consume('receipts', async msg => { await handle(msg); channel.ack(msg); });
# SQS: long polling, process, delete; extend visibility for slow work
aws sqs receive-message --queue-url $Q --wait-time-seconds 20 --max-number-of-messages 10 --visibility-timeout 60
aws sqs change-message-visibility --queue-url $Q --receipt-handle $H --visibility-timeout 300
aws sqs delete-message --queue-url $Q --receipt-handle $HRABBITMQ AND SQS
a smart broker with routing, and a managed queue with visibility timeouts
swipe the figure sideways, or tap expand for full screen
1/5
exchanges and bindings
RabbitMQ publishers send to exchanges; bindings route messages to queues by routing key (direct), pattern (topic: transfer.*.ng) or to all (fanout). Routing logic lives in the broker.
exchanges route to queues by bindingsdirect, topic, fanout