RabbitMQ with Spring AMQP — Concept Check
Questions on RabbitMQ with Spring AMQP. spring-boot-starter-amqp auto-configures RabbitTemplate and a SimpleMessageListenerContainer; declare Exchanges, Queues, and Bindings as Spring beans.
Questions in this quiz
8 questions on RabbitMQ with Spring AMQP — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer configures a RabbitMQ setup with Spring AMQP and notices that messages are not being acknowledged. What could be a likely cause?
- AThe RabbitTemplate is not configured with a MessageConverter.
- BThe Exchange type is incorrectly set as direct instead of topic.
- CThe Queue is not durable.
- DThe acknowledge mode is set to MANUAL but acknowledgments are not sent in code.
2.In a Spring AMQP application, a developer uses `@RabbitListener` but messages are not being consumed. What could be the issue?
- AThe `RabbitAdmin` bean is missing from the configuration.
- BThe `ConnectionFactory` is not set to auto-reconnect.
- CThe queue name in `@RabbitListener` does not match the declared queue.
- DThe `RabbitTemplate` is not configured with a `MessageConverter`.
3.A service using Spring AMQP is experiencing high latency. Which configuration change might help?
- ASet the acknowledge mode to AUTO.
- BUse `SimpleMessageConverter` instead of `Jackson2JsonMessageConverter`.
- CSwitch to `DirectMessageListenerContainer` for lower latency.
- DIncrease the prefetch count to 100.
4.A developer sets up a `RetryInterceptor` with max attempts of 3. What happens if a message fails after 3 retries?
- AIt is discarded without any notification.
- BIt is sent to the Dead Letter Exchange (DLX).
- CIt is automatically acknowledged.
- DIt is requeued indefinitely.
5.What is the role of `RabbitAdmin` in a Spring AMQP application?
- AIt manages message conversion between different formats.
- BIt declares Exchanges, Queues, and Bindings on the broker at startup.
- CIt handles message acknowledgments automatically.
- DIt provides a connection pool to the broker.
6.A developer uses `RabbitTemplate.convertAndSend()` but messages are not reaching the queue. What could be the reason?
- AThe `SimpleRabbitListenerContainerFactory` is not configured.
- BThe queue is not durable.
- CThe `ConnectionFactory` is not set to automatic recovery.
- DThe routing key used does not match any binding.
7.In Spring AMQP, what happens if a `@RabbitListener` method throws a `RecoverableException`?
- AThe message is sent directly to the DLX.
- BThe listener stops processing further messages.
- CThe message is requeued for another attempt.
- DThe message is acknowledged and discarded.
8.Which `MessageConverter` is commonly used for JSON serialization in Spring AMQP?
- AJackson2JsonMessageConverter
- BXmlMessageConverter
- CBinaryMessageConverter
- DSimpleMessageConverter