Bird
0
0

You want to build a Spring Boot app where multiple components react to a user registration event asynchronously. Which approach best fits the event-driven architecture pattern?

hard📝 Application Q15 of 15
Spring Boot - Messaging
You want to build a Spring Boot app where multiple components react to a user registration event asynchronously. Which approach best fits the event-driven architecture pattern?
ASend HTTP requests manually between components
BCall all components directly from the registration method without events
CCreate a UserRegisteredEvent class, publish it with ApplicationEventPublisher, and have multiple @EventListener methods handle it
DUse a database trigger to notify components
Step-by-Step Solution
Solution:
  1. Step 1: Identify event-driven pattern usage

    Creating a custom event class and publishing it allows decoupled communication between components.
  2. Step 2: Understand asynchronous handling

    Multiple @EventListener methods can react independently and asynchronously to the event.
  3. Step 3: Evaluate other options

    Direct calls, database triggers, or manual HTTP requests do not follow Spring Boot event-driven best practices.
  4. Final Answer:

    Create a UserRegisteredEvent class, publish it with ApplicationEventPublisher, and have multiple @EventListener methods handle it -> Option C
  5. Quick Check:

    Custom event + publisher + listeners = Create a UserRegisteredEvent class, publish it with ApplicationEventPublisher, and have multiple @EventListener methods handle it [OK]
Quick Trick: Use custom event class and @EventListener for async reactions [OK]
Common Mistakes:
  • Calling components directly, losing decoupling
  • Relying on database triggers for app events
  • Manually sending HTTP requests between components

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes