spring-boot-event-driven-patterns
Implement event-driven architecture in Spring Boot 3.x using domain events, ApplicationEventPublisher, and Kafka for distributed messaging. This skill covers designing immutable domain events, publishing from aggregate roots, handling events transactionally with @TransactionalEventListener, configuring Kafka producers and consumers, and implementing the outbox pattern for guaranteed event delivery.
Spring Boot Event-Driven Patterns helps you build event-driven systems using domain events, Kafka messaging, and the transactional outbox pattern.
AI-generated summary based on this skill's SKILL.md
Install
giuseppe-trisciuoglio/developer-kit/spring-boot-event-driven-patterns · repository language: Python
git clone https://github.com/giuseppe-trisciuoglio/developer-kit
cp -r developer-kit/plugins/developer-kit-java/skills/spring-boot-event-driven-patterns ~/.claude/skills/spring-boot-event-driven-patternsnpx skillfed install giuseppe-trisciuoglio/developer-kit/spring-boot-event-driven-patternsFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I implement domain events in Spring Boot?
spring-boot-event-driven-patterns teaches you to design immutable domain events and publish them from aggregate roots using ApplicationEventPublisher. Domain events capture state changes within your domain model. You create event classes representing business occurrences, then publish them when aggregates change state. Spring Boot's event infrastructure ensures listeners respond to these events, enabling loose coupling between domain logic and side effects like sending notifications or updating read models.
What is the transactional outbox pattern in Spring Boot?
spring-boot-event-driven-patterns covers the transactional outbox pattern for guaranteed event delivery. This pattern stores events in an outbox table within the same database transaction as your business logic, ensuring atomicity. A separate process polls the outbox and publishes events to Kafka. This prevents message loss if your service crashes between saving data and publishing events, making it essential for reliable distributed systems.
How to set up transactional event listeners and reliable event publishing?
spring-boot-event-driven-patterns shows how to use @TransactionalEventListener to handle events only after the current transaction commits. This prevents processing events from rolled-back transactions. Configure listeners with phase=AFTER_COMMIT to ensure reliability. Combine this with Kafka producers for distributed messaging and implement idempotent handlers to tolerate duplicate deliveries, creating a robust event-driven system.
How do I configure Kafka producers and consumers in Spring Boot?
spring-boot-event-driven-patterns demonstrates Kafka setup using Spring Kafka. Configure producers with KafkaTemplate for publishing events to topics. Use @KafkaListener annotations on consumer methods to subscribe to topics and handle messages. Spring Cloud Stream provides higher-level abstractions for binding producers and consumers to Kafka topics. Configure serialization, error handling, and consumer groups to build scalable distributed messaging.
How can I refactor synchronous microservices to event-driven async?
spring-boot-event-driven-patterns guides refactoring from synchronous REST calls to asynchronous event-driven communication. Replace direct service calls with domain events published to Kafka topics. Services subscribe to relevant events and react independently, improving resilience and scalability. Implement event correlation and tracing to track workflows across services. This decouples services, enables parallel processing, and makes systems more responsive to failures.
What are event-driven microservices best practices in Spring Boot?
spring-boot-event-driven-patterns covers best practices including designing immutable, versioned events; implementing idempotent handlers to tolerate duplicates; using dead letter queues for failed messages; adding correlation IDs for tracing; and applying the outbox pattern for reliability. Handle events transactionally with @TransactionalEventListener, configure appropriate timeouts and retries, and monitor event flow across your distributed system.
SKILL.md
rendered from the published skill — quoted content, verbatim
Spring Boot Event-Driven Patterns
Overview
Implement Event-Driven Architecture (EDA) patterns in Spring Boot 3.x using domain events, ApplicationEventPublisher, @TransactionalEventListener, and distributed messaging with Kafka and Spring Cloud Stream.
When to Use
- Implementing event-driven microservices with Kafka messaging
- Publishing domain events from aggregate roots in DDD architectures
- Setting up transactional event listeners that fire after database commits
- Adding async messaging with producers and consumers via Spring Kafka
- Ensuring reliable event delivery using the transactional
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 11 files
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/SKILL.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/aggregate-root-patterns.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/configuration.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/dependency-setup.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/domain-events-design.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/event-driven-patterns-reference.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/event-handling.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/event-publishing.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/examples.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/outbox-pattern.md
plugins/developer-kit-java/skills/spring-boot-event-driven-patterns/references/testing-strategies.md