spring-boot-event-driven-patterns

Implement domain events and transactional listeners for Spring Boot messaging.

3|Updated Oct 6, 2025
One-click install
npx skills add https://github.com/lgzarturo/springboot-course --skill spring-boot-event-driven-patterns-lgzarturo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spring-boot-event-driven-patterns
Source: https://github.com/lgzarturo/springboot-course/tree/main/.agents/skills/spring-boot-event-driven-patterns
Command: npx skills add https://github.com/lgzarturo/springboot-course --skill spring-boot-event-driven-patterns-lgzarturo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Event-driven patterns in Spring Boot enable reliable asynchronous communication by emitting domain events after transactions and consuming them via Kafka or Spring Cloud Stream, reducing coupling and improving scalability.

Core Features & Use Cases

  • Domain events, ApplicationEventPublisher, and @TransactionalEventListener for post-commit handling
  • Kafka and Spring Cloud Stream integration for distributed messaging
  • Transactional outbox pattern for reliable delivery and observability

Quick Start

Configure your aggregates to emit domain events after commit and attach transactional listeners to publish those events to Kafka or Spring Cloud Stream.

Frequently Asked Questions about spring-boot-event-driven-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I publish domain events in Spring Boot only after a database transaction commits?

Use @TransactionalEventListener with ApplicationEventPublisher to emit domain events after transaction commit, ensuring events are published only when the database changes are durable and reliable.

What is the transactional outbox pattern for event-driven Spring Boot microservices?

The transactional outbox pattern stores domain events in the same database transaction as business state changes, then asynchronously publishes them to Kafka or Spring Cloud Stream for reliable delivery.

Can I use Spring Cloud Stream with Kafka for asynchronous event-driven workflows?

Yes, Spring Cloud Stream integrates with Kafka to consume domain events in asynchronous workflows, reducing service coupling and improving scalability for microservices or modular monoliths.

What's the best way to ensure reliable event delivery when publishing domain events to Kafka?

Implement the transactional outbox pattern to write events to a database table within the business transaction, then relay them to Kafka, preventing event loss during application failures.

Do I need Kafka to implement event-driven patterns in a Spring Boot modular monolith?

No, you can use ApplicationEventPublisher and @TransactionalEventListener for in-process asynchronous communication within a modular monolith, though Kafka or Spring Cloud Stream is needed for distributed microservices.

Why does my @TransactionalEventListener not fire when publishing domain events?

Transactional listeners only fire after a successful transaction commit, so events published outside an active transaction or during a rollback will not trigger the listener execution.