Change Data Streaming Patterns in
Distributed Systems
Gunnar Morling
Software Engineer, Red Hat
@gunnarmorling
Hans-Peter Grahsl
Technical Trainer, Netconomy
@hpgrahsl
Slide 2
Slide 2 text
#CDCPatterns @gunnarmorling @hpgrahsl
… implemented using Change Data Capture
Today’s Objectives
Slide 3
Slide 3 text
#CDCPatterns @gunnarmorling @hpgrahsl
● Open source software engineer at Red Hat
○ Debezium
○ Quarkus
● Spec Lead for Bean Validation 2.0
● Java Champion
● @gunnarmorling
Gunnar Morling
#CDCPatterns @gunnarmorling @hpgrahsl
● Taps into TX log to capture INSERT/UPDATE/DELETE events
● Propagated to consumers via Apache Kafka and Kafka Connect
Debezium — Log-based Change Data Capture
Slide 6
Slide 6 text
#CDCPatterns @gunnarmorling @hpgrahsl
Detour: Data Change Events
● Old and new row state
● Metadata on table, TX id, etc.
● Operation type, timestamp
Slide 7
Slide 7 text
#CDCPatterns @gunnarmorling @hpgrahsl
● Old and new row state
● Metadata on table, TX id, etc.
● Operation type, timestamp
Detour: Data Change Events
Slide 8
Slide 8 text
#CDCPatterns @gunnarmorling @hpgrahsl
● Old and new row state
● Metadata on table, TX id, etc.
● Operation type, timestamp
Detour: Data Change Events
Slide 9
Slide 9 text
Outbox Pattern
Slide 10
Slide 10 text
#CDCPatterns @gunnarmorling @hpgrahsl
● Services need to update their database,
● send messages to other services,
● and that consistently!
The Problem: Microservices Data Exchange
Slide 11
Slide 11 text
#CDCPatterns @gunnarmorling @hpgrahsl
“Dual writes” are prone to inconsistencies!
Outbox Pattern
#CDCPatterns @gunnarmorling @hpgrahsl
● Gradually evolve from old into new
● Support temporary coexistence
● Avoid big bang cut-over
The Problem: Migrating Systems
#CDCPatterns @gunnarmorling @hpgrahsl
● Multiple services need to act collaboratively
to achieve a consistent outcome
● Without 2-phase commit protocols
● Ensure correctness in case of failures
The Problem: Long-running Business Transactions
#CDCPatterns @gunnarmorling @hpgrahsl
● CDC: a powerful tool in the box for
event-driven architectures
● Debezium: open-source CDC for
a variety of databases
● Call to Action:
Would you like built-in Saga support?
Takeaways