Bird
0
0

Given this Spring Boot RabbitMQ listener configuration, what happens when message processing throws an exception?

medium📝 component behavior Q13 of 15
Spring Boot - Messaging
Given this Spring Boot RabbitMQ listener configuration, what happens when message processing throws an exception?
@RabbitListener(queues = "mainQueue")
public void listen(String msg) {
  if(msg.contains("fail")) throw new RuntimeException("Fail");
  System.out.println("Processed: " + msg);
}
Assuming mainQueue has a DLQ configured, what is the expected behavior?
AThe message is retried infinitely without moving to DLQ
BThe application crashes immediately
CThe message is lost without any logging
DThe failed message is sent to the Dead Letter Queue and processing continues
Step-by-Step Solution
Solution:
  1. Step 1: Understand exception handling in RabbitMQ listener

    When an exception occurs, the message is rejected and, if DLQ is configured, routed there.
  2. Step 2: Confirm system behavior with DLQ

    The failed message goes to the Dead Letter Queue, allowing the main queue to continue processing other messages.
  3. Final Answer:

    The failed message is sent to the Dead Letter Queue and processing continues -> Option D
  4. Quick Check:

    Exception triggers DLQ routing [OK]
Quick Trick: Exception sends message to DLQ if configured [OK]
Common Mistakes:
  • Assuming app crashes on exception
  • Thinking message is lost silently
  • Believing infinite retries without DLQ

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes