RabbitTemplate — Concept Check
Questions on RabbitTemplate. RabbitTemplate provides convertAndSend, convertSendAndReceive (synchronous RPC), and receive/receiveAndConvert for flexible produce/consume operations.
Questions in this quiz
8 questions on RabbitTemplate — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.You are using RabbitTemplate's convertAndSend method to publish messages. What happens if the message is unroutable?
- AThe message is automatically rerouted to a default exchange.
- BThe message is lost and no error is reported.
- CThe message is stored in a dead-letter queue by default.
- DThe message is returned via a return callback if mandatory is set to true.
2.A developer uses convertSendAndReceive for an RPC call but receives null. What could be the reason?
- AThe message was sent to the wrong exchange.
- BThe reply did not arrive within the replyTimeout period.
- CThe correlation ID was not set correctly.
- DThe server did not process the request due to a syntax error.
3.How does RabbitTemplate handle message serialization by default?
- ASerializes using XML by default.
- BUses Java serialization for all objects.
- CRequires a custom MessageConverter to be set.
- DUses SimpleMessageConverter for byte arrays.
4.A service using RabbitTemplate for synchronous RPC is experiencing timeouts. What should you investigate first?
- ACheck the network latency between services.
- BVerify the exchange and routing key are correct.
- CIncrease the replyTimeout setting.
- DEnsure the mandatory flag is set to true.
5.What is the role of the correlation ID in RabbitTemplate's RPC pattern?
- AIt ensures messages are delivered in order.
- BIt matches requests with their replies.
- CIt specifies the message expiration time.
- DIt sets the priority of the message.
6.A developer sets up RabbitTemplate with publisher confirms. What is the benefit?
- AIt guarantees the message will be delivered to the consumer.
- BIt automatically retries sending messages on failure.
- CIt verifies that the broker has accepted the message.
- DIt ensures messages are delivered in the order they were sent.
7.When using convertAndSend, how can you set custom headers for a message?
- AInclude headers in the message body as a JSON object.
- BUse a special exchange type that supports headers.
- CSet headers directly in the RabbitTemplate configuration.
- DUse a MessagePostProcessor to modify the message before sending.
8.What happens if you do not set a MessageConverter in RabbitTemplate?
- ASimpleMessageConverter is used by default.
- BMessages cannot be sent without a converter.
- CJackson2JsonMessageConverter is used by default.
- DThe application will throw an error on startup.