Skip to main content
InterviewHubPRO
Section Overview
Q24

Question 24 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

48%
RabbitMQ & AMQP (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

How do you handle Poison Pill messages and infinite redelivery loops?

senior LevelCode ExampleSystem Design

In Simple Words: In RabbitMQ Quorum Queues, use the built-in x-delivery-limit parameter:

javascript
await channel.assertQueue('invoices_queue', {
  arguments: {
    'x-queue-type': 'quorum',
    'x-delivery-limit': 5, // Max 5 delivery attempts
    'x-dead-letter-exchange': 'invoices_dlx'
  }
});

Every time a message is rejected and requeued, RabbitMQ increments the x-delivery-count header. Once the count reaches 5, RabbitMQ automatically routes the message to invoices_dlx and frees the queue.