Bird
0
0

Given this Spring Boot code snippet:

medium📝 component behavior Q4 of 15
Spring Boot - Messaging
Given this Spring Boot code snippet:
@JmsListener(destination = "orders")
public void receiveOrder(String order) {
  System.out.println("Order received: " + order);
}

What will be printed if a message "Book123" is sent to the 'orders' queue?
ANo output, method not triggered
BOrder received: Book123
CBook123
DOrder received: orders
Step-by-Step Solution
Solution:
  1. Step 1: Understand @JmsListener behavior

    The method listens to the 'orders' queue and receives messages sent there.
  2. Step 2: Analyze method output

    The method prints "Order received: " plus the message content, so it prints "Order received: Book123".
  3. Final Answer:

    Order received: Book123 -> Option B
  4. Quick Check:

    Message output = printed message with content [OK]
Quick Trick: Listener prints message content prefixed [OK]
Common Mistakes:
  • Confusing queue name with message content
  • Expecting no output if listener is correct
  • Printing only message without prefix

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes