Bird
0
0

Given the code snippet:

medium📝 component behavior Q4 of 15
Spring Boot - Messaging
Given the code snippet:
rabbitTemplate.convertAndSend("myExchange", "myKey", "Hello")

What happens if the exchange "myExchange" does not exist?
AThe message is sent to the default exchange instead
BThe message is silently dropped without error
CThe exchange is automatically created and message sent
DAn exception is thrown at runtime indicating the exchange is missing
Step-by-Step Solution
Solution:
  1. Step 1: Understand RabbitMQ behavior on missing exchange

    If a message is sent to a non-existent exchange, RabbitMQ throws a channel-level exception.
  2. Step 2: Check Spring Boot RabbitTemplate behavior

    Spring's RabbitTemplate propagates this exception at runtime, so the application will get an error.
  3. Final Answer:

    An exception is thrown at runtime indicating the exchange is missing -> Option D
  4. Quick Check:

    Missing exchange causes runtime exception [OK]
Quick Trick: Missing exchange causes runtime error, not silent failure [OK]
Common Mistakes:
  • Assuming message is dropped silently
  • Thinking exchange auto-creates on send
  • Believing message routes to default exchange automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes