Complete the code to declare a dead letter queue in Spring Boot.
Queue deadLetterQueue() {
return new Queue("[1]", true);
}The dead letter queue is usually named distinctly, here "myDeadLetterQueue" is the correct name.
Complete the code to bind the dead letter queue to the dead letter exchange.
Binding deadLetterBinding(Queue deadLetterQueue, DirectExchange deadLetterExchange) {
return BindingBuilder.bind(deadLetterQueue).to(deadLetterExchange).with("[1]");
}The dead letter queue is bound using the dead letter routing key.
Fix the error in the queue declaration to enable dead letter exchange support.
Map<String, Object> args = new HashMap<>(); args.put("[1]", "deadLetterExchange"); Queue queue = new Queue("mainQueue", true, false, false, args);
The argument key "x-dead-letter-exchange" tells the queue which exchange to use for dead letters.
Fill both blanks to configure a queue with dead letter exchange and dead letter routing key.
Map<String, Object> args = new HashMap<>(); args.put("[1]", "deadLetterExchange"); args.put("[2]", "deadLetterRoutingKey"); Queue queue = new Queue("mainQueue", true, false, false, args);
Both keys are needed: one for the dead letter exchange and one for the routing key.
Fill all three blanks to create a dead letter queue, dead letter exchange, and bind them with a routing key.
Queue deadLetterQueue() {
return new Queue("[1]", true);
}
DirectExchange deadLetterExchange() {
return new DirectExchange("[2]");
}
Binding deadLetterBinding() {
return BindingBuilder.bind(deadLetterQueue()).to(deadLetterExchange()).with("[3]");
}The dead letter queue, exchange, and routing key must be named consistently to work together.