Challenge - 5 Problems
RabbitMQ Integration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What happens when a Spring Boot RabbitMQ listener receives a message?
Consider a Spring Boot application with a RabbitMQ listener method annotated with
@RabbitListener. What is the expected behavior when a message arrives in the queue?Spring Boot
public class MessageListener { @RabbitListener(queues = "testQueue") public void receiveMessage(String message) { System.out.println("Received: " + message); } }
Attempts:
2 left
💡 Hint
Think about how Spring Boot handles methods annotated with @RabbitListener.
✗ Incorrect
Spring Boot automatically calls methods annotated with @RabbitListener when a message arrives in the specified queue, passing the message content as the method argument.
📝 Syntax
intermediate2:00remaining
Which code snippet correctly declares a RabbitMQ queue bean in Spring Boot?
You want to declare a RabbitMQ queue named "myQueue" as a Spring bean. Which option is correct?
Attempts:
2 left
💡 Hint
Remember that @Bean annotation is needed and the constructor requires queue name and durability.
✗ Incorrect
Option D correctly declares a durable queue bean with the @Bean annotation and proper constructor parameters.
🔧 Debug
advanced2:00remaining
Why does this Spring Boot RabbitMQ listener fail to receive messages?
Given the code below, why does the listener not receive any messages from the queue?
Spring Boot
public class Listener { @RabbitListener(queues = "orders") public void listen(String msg) { System.out.println("Order: " + msg); } } // Application properties: spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 // No queue bean declared in configuration.
Attempts:
2 left
💡 Hint
Check if the listener class is a Spring-managed bean.
✗ Incorrect
The listener class must be annotated with @Component (or equivalent like @Service) to be detected by Spring's component scan. Without it, the @RabbitListener method is not processed and registered.
❓ state_output
advanced2:00remaining
What is the output when sending a message with RabbitTemplate?
Given the code below, what will be printed to the console?
Spring Boot
public class Sender { private final RabbitTemplate rabbitTemplate; public Sender(RabbitTemplate rabbitTemplate) { this.rabbitTemplate = rabbitTemplate; } public void send() { rabbitTemplate.convertAndSend("myExchange", "myRoutingKey", "Hello World"); System.out.println("Message sent"); } } // Assume exchange and queue are properly configured and bound.
Attempts:
2 left
💡 Hint
Focus on what the code explicitly prints.
✗ Incorrect
The code prints "Message sent" after sending the message. The actual message is sent to RabbitMQ but not printed here.
🧠 Conceptual
expert2:00remaining
Which statement best describes the role of RabbitMQ exchanges in Spring Boot integration?
In Spring Boot RabbitMQ integration, what is the primary role of an exchange?
Attempts:
2 left
💡 Hint
Think about how messages find their way to queues.
✗ Incorrect
Exchanges receive messages and route them to queues according to routing keys and bindings. They do not store or encrypt messages.