Visão Geral
O curso Event Sourcing with Kafka apresenta de forma prática como implementar arquiteturas baseadas em event sourcing utilizando o Apache Kafka como event log distribuído.
Os participantes aprenderão a modelar eventos, projetar estados derivados (projections/read models), reprocessar eventos, implementar consistência eventual, lidar com versionamento de eventos, utilizar Kafka Streams/ksqlDB como mecanismo de projeção e aplicar padrões de mercado como CQRS e Saga.
O curso é altamente prático, com laboratórios individuais e foco em aplicações de produção.
Conteúdo Programatico
1. Introduction to Event Sourcing
- What is event sourcing?
- Events vs snapshots vs state
- Command → Event → State changes
- Advantages and challenges
- Event sourcing vs message passing vs log-based systems
2. Apache Kafka as an Event Store
- Why Kafka fits event sourcing
- Topics, partitions, retention, compaction
- Kafka as a distributed, immutable event log
- Understanding event ordering and partition keys
3. Event Modeling
- Defining domain events
- Idempotency
- Event naming conventions
- Designing event schemas
- Using Schema Registry
- Backward and forward compatibility
4. Implementing Write Models
- Command handling
- Validations and business logic
- Producing domain events to Kafka
- Ensuring atomic event writes
- Transactional outbox pattern vs direct event sourcing
5. Implementing Read Models (Projections)
- What are projections?
- When and why to use read models
- Projection consistency
- Materialized views
- Rebuilding projections from scratch
6. Projections with Kafka Streams
- KStream/KTable for projections
- Aggregations and transformations
- Windowed and session-based projections
- Local state stores and recovery
- Interactive queries to expose read models
7. Projections with ksqlDB (Optional)
- Creating streams and tables
- Aggregations using SQL
- Creating materialized views
- Exposing read-side APIs
8. Reprocessing and Replaying Events
- Replaying entire event histories
- Resetting consumer groups
- Strategies for rebuilding read models
- Handling large event histories
9. Data Storage and Snapshots
- When to snapshot
- Hybrid event sourcing (events + snapshots)
- Storing snapshots outside Kafka
- Reconciliation strategies
10. CQRS with Kafka
- Separation of command and query responsibilities
- CQRS patterns
- CQRS without event sourcing
- CQRS combined with event sourcing
11. Distributed Transactions and Sagas
- Why distributed transactions are avoided
- Saga orchestration vs choreography
- Event-driven sagas in Kafka
- Compensating actions and rollback events
12. Governance, Security, and Versioning
- Event catalogs
- Event versioning strategies
- Event deprecation policies
- Security and data privacy considerations
- GDPR considerations (immutability vs right to delete)
13. Observability and Monitoring
- Monitoring Kafka consumer lag
- Monitoring projection services
- Tracking failed events
- Schema validation and error handling
- DLQ strategies
14. Hands-on Labs
- Creating an event-sourced domain model
- Producing commands and generating events
- Building projections with Kafka Streams
- Rebuilding a read model from historical events
- Creating a saga that spans multiple services
- Implementing snapshots
- Monitoring and debugging an event-sourced system
15. Best Practices
- Choosing partition keys for event streams
- Avoiding anti-patterns in event sourcing
- Designing maintainable event schemas
- Ensuring replay safety
- Production considerations