Bird
0
0

What is wrong with this Spring Boot RabbitMQ listener method for handling dead letter messages?

medium📝 Debug Q7 of 15
Spring Boot - Messaging
What is wrong with this Spring Boot RabbitMQ listener method for handling dead letter messages? @RabbitListener(queues = "dlq") public void handleDlq(String message) { // process dead letter message throw new RuntimeException("error"); } Options:
ADead letter queue cannot have listeners
BListener method must return a boolean
CThrowing exception causes message to be requeued infinitely
DMethod parameter type should be Message, not String
Step-by-Step Solution
Solution:
  1. Step 1: Analyze exception in DLQ listener

    Throwing an exception in DLQ listener causes message rejection and requeue if requeue is true.
  2. Step 2: Understand infinite requeue risk

    Without special handling, this leads to infinite retries and possible message flooding.
  3. Final Answer:

    Throwing exception causes message to be requeued infinitely -> Option C
  4. Quick Check:

    Exception in DLQ listener = infinite requeue risk [OK]
Quick Trick: Avoid exceptions in DLQ listener to prevent infinite retries [OK]
Common Mistakes:
  • Thinking DLQ can't have listeners
  • Believing method signature is wrong
  • Ignoring requeue behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes