Bird
Raised Fist0
Spring Bootframework~20 mins

Dead letter queues in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Dead Letter Queue Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
What happens when a message is rejected without requeue in a Spring Boot RabbitMQ listener with DLQ configured?
Consider a Spring Boot application using RabbitMQ with a dead letter queue (DLQ) configured. If a message listener rejects a message without requeueing it, what is the expected behavior?
Spring Boot
public void listen(String message) {
    if(message.contains("fail")) {
        throw new RuntimeException("Processing failed");
    }
    System.out.println("Processed: " + message);
}
AThe message is sent to the dead letter queue for later inspection.
BThe message is discarded and lost permanently.
CThe message is requeued and retried indefinitely.
DThe message is logged but remains in the original queue.
Attempts:
2 left
💡 Hint
Think about what happens to messages that cannot be processed and are rejected without requeue.
📝 Syntax
intermediate
2:00remaining
Which Spring Boot annotation correctly configures a dead letter queue for a RabbitMQ listener?
You want to configure a dead letter queue for a RabbitMQ listener in Spring Boot. Which annotation usage is correct?
A@RabbitListener(queues = "myQueue", dlq = "myDLQ")
B@RabbitListener(queues = "myQueue", deadLetterExchange = "dlx")
C
@RabbitListener(bindings = @QueueBinding(value = @Queue(value = "myQueue", durable = true, arguments = {
    @Argument(name = "x-dead-letter-exchange", value = "dlx")
})))
D@RabbitListener(queues = "myQueue", deadLetterQueue = "myDLQ")
Attempts:
2 left
💡 Hint
Dead letter queues are configured via queue arguments in Spring AMQP.
❓ state_output
advanced
2:00remaining
What is the state of the message after max retry attempts are exceeded with DLQ configured?
In a Spring Boot RabbitMQ setup with a dead letter queue and retry mechanism, what happens to a message after it exceeds the maximum retry attempts?
AThe message is moved to the dead letter queue for further analysis.
BThe message is marked as processed and ignored.
CThe message is deleted from the queue and lost.
DThe message is sent back to the original queue for infinite retries.
Attempts:
2 left
💡 Hint
Consider what happens when retries fail repeatedly in a system with DLQ.
🔧 Debug
advanced
2:00remaining
Why does the dead letter queue not receive messages despite configuration?
A Spring Boot application has a dead letter queue configured for RabbitMQ, but messages that fail processing are not appearing in the DLQ. What is the most likely cause?
AThe DLQ is not bound to the dead letter exchange.
BThe message TTL is set too high.
CThe listener method is not throwing exceptions on failure.
DThe original queue is missing the x-dead-letter-exchange argument in its declaration.
Attempts:
2 left
💡 Hint
Check the queue arguments and bindings carefully.
🧠 Conceptual
expert
3:00remaining
What is the primary benefit of using a dead letter queue in a Spring Boot microservice architecture?
Why is it important to use dead letter queues in a Spring Boot microservice system that processes messages asynchronously?
ATo permanently discard all failed messages and reduce queue size.
BTo isolate and analyze failed messages without blocking the main processing flow.
CTo automatically retry failed messages indefinitely until success.
DTo encrypt messages for secure transmission between services.
Attempts:
2 left
💡 Hint
Think about how failures should be handled without stopping the system.

Practice

(1/5)
1. What is the main purpose of a Dead Letter Queue (DLQ) in Spring Boot messaging?
easy
A. To speed up message processing by duplicating messages
B. To hold messages that failed processing and prevent blocking the main queue
C. To permanently delete messages after processing
D. To encrypt messages for security

Solution

  1. Step 1: Understand message failure handling

    Dead Letter Queues are designed to store messages that cannot be processed successfully.
  2. Step 2: Identify the role of DLQ in queue management

    DLQs keep the main queue clean by isolating failed messages, allowing the system to continue processing other messages.
  3. Final Answer:

    To hold messages that failed processing and prevent blocking the main queue -> Option B
  4. Quick Check:

    DLQ purpose = hold failed messages [OK]
Hint: DLQ stores failed messages to keep main queue flowing [OK]
Common Mistakes:
  • Thinking DLQ speeds up processing by duplicating messages
  • Confusing DLQ with message deletion
  • Assuming DLQ encrypts messages
2. Which of the following is the correct way to configure a Dead Letter Queue in Spring Boot using RabbitMQ?
easy
A. Set queue argument x-dead-letter-exchange and x-dead-letter-routing-key
B. Set queue argument x-message-ttl only
C. Use @EnableDeadLetterQueue annotation on the listener
D. Configure spring.rabbitmq.dlq.enabled=true in application.properties

Solution

  1. Step 1: Identify DLQ configuration parameters

    Dead Letter Queues require setting the queue arguments x-dead-letter-exchange and x-dead-letter-routing-key to route failed messages.
  2. Step 2: Eliminate incorrect options

    x-message-ttl controls message time-to-live, not DLQ; no @EnableDeadLetterQueue annotation exists; no direct property spring.rabbitmq.dlq.enabled.
  3. Final Answer:

    Set queue argument x-dead-letter-exchange and x-dead-letter-routing-key -> Option A
  4. Quick Check:

    DLQ config = x-dead-letter-exchange + routing key [OK]
Hint: DLQ needs dead-letter-exchange and routing-key set [OK]
Common Mistakes:
  • Confusing TTL with DLQ configuration
  • Looking for non-existent annotations
  • Expecting simple property toggle for DLQ
3. 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?
medium
A. The message is retried infinitely without moving to DLQ
B. The application crashes immediately
C. The message is lost without any logging
D. The failed message is sent to the Dead Letter Queue and processing continues

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]
Hint: 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
4. You configured a Dead Letter Queue but messages are not arriving there after failures. Which of the following is the most likely cause?
medium
A. The message payload is empty
B. The listener method does not throw exceptions
C. The main queue is missing the x-dead-letter-exchange argument
D. The DLQ name is too long

Solution

  1. Step 1: Check DLQ configuration completeness

    If the main queue lacks the x-dead-letter-exchange argument, failed messages have no route to DLQ.
  2. Step 2: Evaluate other options

    Listener throwing exceptions is needed but not sufficient; DLQ name length and empty payload do not prevent DLQ routing.
  3. Final Answer:

    The main queue is missing the x-dead-letter-exchange argument -> Option C
  4. Quick Check:

    Missing DLX argument blocks DLQ routing [OK]
Hint: DLQ needs dead-letter-exchange set on main queue [OK]
Common Mistakes:
  • Ignoring missing DLX argument
  • Blaming listener behavior alone
  • Worrying about DLQ name length unnecessarily
5. You want to implement a retry mechanism for failed messages before sending them to the Dead Letter Queue in Spring Boot. Which approach correctly combines retries and DLQ usage?
hard
A. Use a retry interceptor on the listener and configure DLQ for messages failing all retries
B. Send all messages directly to DLQ and manually retry them later
C. Disable DLQ and rely only on retry count in listener
D. Configure DLQ without retry; retries happen automatically by RabbitMQ

Solution

  1. Step 1: Understand retry and DLQ roles

    Retries allow multiple attempts to process a message before considering it failed.
  2. Step 2: Combine retry interceptor with DLQ

    Configure a retry interceptor on the listener to retry processing; if all retries fail, the message is routed to the DLQ.
  3. Step 3: Eliminate incorrect options

    Sending all messages directly to DLQ skips normal processing; disabling DLQ loses failed message tracking; RabbitMQ does not retry automatically without app logic.
  4. Final Answer:

    Use a retry interceptor on the listener and configure DLQ for messages failing all retries -> Option A
  5. Quick Check:

    Retry interceptor + DLQ = robust failure handling [OK]
Hint: Retry in listener, then DLQ for final failures [OK]
Common Mistakes:
  • Sending all messages directly to DLQ
  • Disabling DLQ and expecting retries only
  • Assuming RabbitMQ retries automatically
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard