Event-driven architecture in Spring Boot allows different components or microservices to communicate by publishing and consuming events instead of calling each other directly. This approach reduces coupling, improves scalability, and makes the system easier to maintain and extend.
Consider an e-commerce application where a customer places an order.
Order Service
↓
Payment Service
↓
Inventory Service
↓
Notification Service
Each service directly depends on another service.
Order Created Event
↓
Payment Service
Inventory Service
Notification Service
Analytics Service
All services react independently to the same event without knowing about each other.
Create Event:
public class OrderCreatedEvent {
private final Long orderId;
public OrderCreatedEvent(Long orderId) {
this.orderId = orderId;
}
public Long getOrderId() {
return orderId;
}
}@Service
public class OrderService {
private final ApplicationEventPublisher publisher;
public OrderService(
ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public void createOrder() {
// Order creation logic
publisher.publishEvent(
new OrderCreatedEvent(101L));
}
}@Component
public class NotificationListener {
@EventListener
public void handleOrderCreated(
OrderCreatedEvent event) {
System.out.println(
"Sending confirmation email for order: "
+ event.getOrderId());
}
}@EnableAsync
@Async
@EventListener
public void handleOrderCreated(
OrderCreatedEvent event) {
// Background processing
}This prevents long-running tasks from blocking the main request thread.
Order Service
↓
Kafka Topic
↓
Payment Service
Notification Service
Inventory Service
Shipping Service
A concise interview answer is: Spring Boot supports event-driven architecture using ApplicationEventPublisher and @EventListener for internal events, and messaging platforms such as Kafka or RabbitMQ for microservices communication. This enables loosely coupled, scalable, and maintainable systems where services react to events instead of directly invoking one another.
Last updated: 16 July 2026
Previous question: How do you handle a 404 error in Spring Boot?
Next question: What are the basic annotations that Spring Boot offers?