SlideShare a Scribd company logo
Implementing Domain Events with
Kafka
Devtalks
How DDD and Kafka help in integrating microservices
Bucharest, 12th of June 2020
,
Agenda
2
Challenges in integrating microservices
What is a Domain Event?
Implementation patterns for Domain Events
Kafka Delivery Guarantees & Configurations
Microservices benefits
• Agility in development
• Better understanding of the architecture
• Resilience in production
• Independent scalability of microservices
• Independent deployment of microservices
• Fault tolerance (failures in a microservice can be isolated from other microservices)
How can these benefits could be achieved?
✓ Ensuring microservice autonomy
✓ Defining explicit contracts
3
Synchronous Integration between Microservices
▪ Temporal Coupling
▪ Behavioral Coupling*
The services are not autonomous
Complex and unreliable
compensation logic
Circuit breaker, timeouts, retries
etc. are of limited use
*Reference: http://iansrobinson.com/2009/04/27/temporal-and-behavioural-coupling/
4
Introduction to DDD
▪ Strategic Design:
✓ bounded contexts
✓ context map
▪ Tactical Design:
✓ entities
✓ values
✓ aggregates
✓ aggregate roots
✓ Repositories
✓ services
✓ domain events
✓ application services
5
Reference: Evans, Eric. Domain-Driven Design: Tackling Complexity in the Heart of Software. Boston: Addison-Wesley, 2003, Vernon, Vaughn. Implementing Domain-Driven Design. Boston: Addison-
Wesley, 2013.
Microservices Design Rules
1 microservice = 1 bounded context = 1 deployment unit
1 operation = 1 transaction = 1 aggregate (modify in one transaction only one
aggregate instance)
Prefer asynchronous communication between microservices over synchronous
request/reply integration ➔ integration based on domain events
6
Domain Events
• An event captures the changes in the state of a single aggregate
• Events are immutable
• They get published by the aggregates and contain the associated aggregate root id
• Each event should have a unique id that could be used for de-duplication
7
Integration Rules between Bounded Contexts
▪ Via a publish/subscriber messaging infrastructure
▪ The bounded contexts interested in the data maintained by other bounded
contexts subscribe to the relevant events
▪ Integration via events is applicable also between different aggregate instances from
the same bounded context
8
➔ Transactional Consistency within aggregate boundaries
➔ Eventual Consistency between different bounded contexts and between different
aggregate instances
µ Service µ Service µ Service µ Service
Event Bus
REST/SOAP REST/SOAP REST/SOAP REST/SOAP
UI/ API Gateway
Data DataDataData
Microservices Architecture based on DDD
Decomposing application into loosely
coupled services:
- Explicit contract/ interface
- Boundary alignment with
business capabilities
- Asynchronous communication
between microservices
- Microservices have their own
storage (they are the
authoritative source of data for
their domain)
1
2
3
4
1
2
3
4
9
Main use cases for domain events
10
Notifications other
bounded contexts need
to react to
Data replication over
events between
bounded contexts
CQRS (in the same
bounded context)
Messaging requirements in view of DDD
▪ Support for publish/subscriber pattern
▪ Support for competing consumers pattern
▪ Persistence and Durability
▪ At-least-once message delivery
▪ Partial message ordering (per aggregate)
11
Kafka Logical Architecture
12
Replication + Fault Tolerance +
Partitioning + Elastic Scaling
Single-Leader System (all
producers/consumers
publish/fetch data to/from
leaders )
CP in terms of CAP theorem for
both write and read operations
Confluent Platform 5.4 introduces
Follower Fetching, Observers, and
Replica Placement ➔ Fetching
data from asynchronous replicas
➔ AP for read operations
Availability ZoneAvailability Zone
Broker B1 – Leader for partition 1,
follower for partitions 3 and 4
Broker B2 – Leader for 2, follower
for 1 and 4
Topic-partition1
Broker B3 – Leader for 3, follower for
1 and 2
Broker B4– Leader for 4, follower
for 2 and 3
Topic-partition2
Topic-partition3
Topic-partition4
Topic-partition1
Topic-partition1
fetch
fetch
Topic-partition2 Topic-partition2
fetchfetch
Topic-partition3
Topic-partition3
fetch
fetch
Topic-partition4 Topic-partition4
fetchfetch
Producer/
Consumer
Initial ISR: {B1, B2, B3}
Initial ISR: {B2, B3, B4}
Initial ISR: {B1, B3, B4}
Initial ISR: {B1, B2, B4}
Kafka Broker Configurations
min.insync.replicas: should be set to a value greater than 1
replica.lag.time.max.ms
unclean.leader.election.enable: should be false
broker.rack: should reflect data centers, regions or availability zones where
brokers are placed
replica.selector.class (since Confluent 5.4): used by the broker to find the
preferred read replica. By default it returns partition leaders.
13
* Reference: https://docs.confluent.io/current/installation/configuration/broker-configs.html
Kafka Offsets
14
0 1 2 cp up hw ...lc end
Begin
Offset
Last
Commited
Offset of a
Consumer
Consumer s
Current Position
Undereplicated
Partition
from a follower
non-ISR broker
High Watermark
(last index
replicated to all ISR)
Messages published with
acks 0 or 1 and not yet
replicated
Consumer s batch of
messages
How to choose the number of topics/partitions
▪ Number of partitions = producer throughput/ consumer throughput
▪ limit the number of partitions per broker to 100 x b x r,
Where:
b is the number of brokers in a Kafka cluster
r is the replication factor
Why?
“Kafka broker uses only a single thread to replicate data from another broker, for all
partitions that share replicas between the two brokers. (…)replicating 1000 partitions from
one broker to another can add about 20 ms latency, which implies that the end-to-end
latency is at least 20 ms.”*
15
* Reference: https://www.confluent.io/blog/how-choose-number-topics-partitions-kafka-cluster/
How Kafka addresses DDD messaging requirements
Support for publish/subscribers pattern ➔ topics
Support for competing consumers pattern ➔ consumer groups
Persistence and Durability ➔ replication factors, ISR, retention policies
At-least-once message delivery ➔ acks (on producer-side), default behavior of
consumers (when auto commit is enabled)
Partial message ordering (per aggregate) ➔ partitions
16
Application Requirements in View of DDD
▪ Domain events are self-contained messages (events capture the state changes
in domain entities and provide decision support for subscribers)
▪ Domain events are part of a microservice's public API/contract
▪ One topic per aggregate type
▪ Partitioning by aggregate/entity ID
▪ Transactional semantics when publishing events
▪ Events deduplication on subscriber-side for achieving exactly-once delivery
semantics
17
Aggregate Processing
18
Client Application Service Aggregate Root Entity Repository KafkaProducer
remote operation
Aggregate root method
Entity method
Publish event: event type, root id, event id,
aggregate root state change, entity state change
Find aggregate
State change
State change
Save aggregate
Bounded Context
Transactional Publishing Patterns
19
Client Application Service Aggregate Root Repository Event Publisher
remote operation
Aggregate root method
Find aggregate
local transaction
Bounded Context
Events Table
(same DB)
KafkaProducer
State change
Polling Publisher
send
Update offset
loop
Kafka Producer
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("acks", "all");
props.put("key.serializer", "io.confluent.kafka.serializers.KafkaAvroSerializer");
props.put("value.serializer", "io.confluent.kafka.serializers.KafkaAvroSerializer");
….
Producer<String, String> producer = new KafkaProducer<>(props);
….
Future<RecordMetadata> metadata = producer.send(new ProducerRecord<String, String>("my-topic", key, value));
….
producer.close()
20
Kafka Producer Configurations
acks = all
retries = 2147483647.
delivery.timeout.ms
enable.idempotence = true.
max.in.flight.requests.per.connection = 1.
21
* Reference: https://docs.confluent.io/current/installation/configuration/producer-configs.html
Kafka Consumer
try {
while (true) {
ConsumerRecords<String, String> records = consumer.poll(MAX_VALUE);
for (ConsumerRecord<String, String> record : records) {
System.out.println(record.offset() + “: ” + record.value());
}
try {
//saving new offsets if enable.auto.commit = false
} catch (CommitFailedException e) {
// application specific failure handling
}
}
} catch (WakeupException e) {
// ignore for shutdown
} finally {
consumer.close();
}
22
Up to
max.poll.records
max.poll.interval.ms >
max.poll.records
*
record processing time
Commit if enable.auto.commit = true and
the interval between current poll and last
commit >=
auto.commit.interval.ms
Kafka Consumer Configurations
▪ group.id
▪ heartbeat.interval.ms & session.timeout.ms
▪ enable.auto.commit & auto.commit.interval.ms
▪ isolation.level
▪ max.poll.interval.ms
▪ max.poll.records
▪ client.rack (since Confluent 5.4; if the partition is rack aware and the replica selector is set, pick a “preferred
read replica”)
23
Exactly-once Stateful Processing
24
Kafka Broker(s) Kafka Consumer Aggregate Root Repository Offset Manager
Poll for events
Aggregate root method
Save aggregate
events
local transaction
Bounded Context
Offsets Table
Aggregate State
Table
Select offsets
State change
Update Offset
Same Database
loop
Avro Consumers & Producers
25
Schema
Registry
Kafka
Producer Consumer
Send Avro content +
Schema id
Query schema id
by schema content
Get writer s
schema by id
Read avro
content + schema Id
Apply schema
evolution
Avro
• Kafka records can have a Key and a Value and both can have a schema.
• There is a compatibility level (BACKWARDS, FORWARDS, FULL, NONE) setting for the Schema
Registry and an individual subject. Versions are also managed per subject
• Backward compatibility = consumers coded with a newer schema can read messages
written with older schema.
• Forward compatibility = consumers coded with a older schema can read messages written
with a newer schema.
• Full compatibility = a new schema version is both backward and forward compatible.
• None
• Avro schema evolution is an automatic transformation of messages from the schema used by
producers to write into the Kafka log to schema used by consumer to read them. The
transformation occurs at consuming time in Avro Deserializer.
26
Change Type Order of releasing into production
Backward Compatible Consumers, Producers
Forward Compatible Producers, Consumers (after they finish reading old messages)
Fully Compatible Order doesn’t matter
None Coordinated
Subject Name Strategy
• A DDD aggregate could publish multiple event types, each capturing a distinct business intent
• For maintaining the correct event order all the events will be published in the same topic (using
aggregate id as message key)
• Multiple event types require multiple schemas (one for each event type that could be published
in the same topic)
• Producer-side configs:
• schema registry url
• key.subject.name.strategy (which defines how to construct the subject name for message
keys) = TopicNameStrategy, RecordNameStrategy or TopicRecordNameStrategy
• value.subject.name.strategy (how to construct the subject name for message values) =
TopicNameStrategy, RecordNameStrategy or TopicRecordNameStrategy
• Consumer-side configs:
• specific.avro.reader = true (or otherwise you get Avro GenericRecord)
27
Conclusions
Domain Driven Design not only helps in decomposing a system into
microservices aligned with business capabilities, but also offers essential
lessons on:
✓ how to achieve resilience
✓ how to achieve scalability
by decoupling microservices using domain events
28
Thank you!

More Related Content

What's hot

Microservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanMicroservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, Kanban
Araf Karsh Hamid
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Araf Karsh Hamid
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
Saroj Panyasrivanit
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDD
Dennis Doomen
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
Jeff Holoman
 
APACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsAPACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka Streams
Ketan Gote
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
Araf Karsh Hamid
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
Araf Karsh Hamid
 
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
Chris Richardson
 
kafka
kafkakafka
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
Araf Karsh Hamid
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
Araf Karsh Hamid
 
Elastic-Engineering
Elastic-EngineeringElastic-Engineering
Elastic-Engineering
Araf Karsh Hamid
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and Kafka
Araf Karsh Hamid
 
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Kai Wähner
 
Serverless Kafka on AWS as Part of a Cloud-native Data Lake Architecture
Serverless Kafka on AWS as Part of a Cloud-native Data Lake ArchitectureServerless Kafka on AWS as Part of a Cloud-native Data Lake Architecture
Serverless Kafka on AWS as Part of a Cloud-native Data Lake Architecture
Kai Wähner
 
A visual introduction to Apache Kafka
A visual introduction to Apache KafkaA visual introduction to Apache Kafka
A visual introduction to Apache Kafka
Paul Brebner
 
Kafka presentation
Kafka presentationKafka presentation
Kafka presentation
Mohammed Fazuluddin
 
Event Driven Microservices architecture
Event Driven Microservices architectureEvent Driven Microservices architecture
Event Driven Microservices architecture
NikhilBarthwal4
 
Event driven architecture
Event driven architectureEvent driven architecture
Event driven architecture
Shadrach Jabonir
 

What's hot (20)

Microservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, KanbanMicroservices, Containers, Kubernetes, Kafka, Kanban
Microservices, Containers, Kubernetes, Kafka, Kanban
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SRE
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDD
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
APACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsAPACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka Streams
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
Melbourne Jan 2019 - Microservices adoption anti-patterns: Obstacles to decom...
 
kafka
kafkakafka
kafka
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
Elastic-Engineering
Elastic-EngineeringElastic-Engineering
Elastic-Engineering
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and Kafka
 
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
Confluent REST Proxy and Schema Registry (Concepts, Architecture, Features)
 
Serverless Kafka on AWS as Part of a Cloud-native Data Lake Architecture
Serverless Kafka on AWS as Part of a Cloud-native Data Lake ArchitectureServerless Kafka on AWS as Part of a Cloud-native Data Lake Architecture
Serverless Kafka on AWS as Part of a Cloud-native Data Lake Architecture
 
A visual introduction to Apache Kafka
A visual introduction to Apache KafkaA visual introduction to Apache Kafka
A visual introduction to Apache Kafka
 
Kafka presentation
Kafka presentationKafka presentation
Kafka presentation
 
Event Driven Microservices architecture
Event Driven Microservices architectureEvent Driven Microservices architecture
Event Driven Microservices architecture
 
Event driven architecture
Event driven architectureEvent driven architecture
Event driven architecture
 

Similar to Implementing Domain Events with Kafka

New Features in Confluent Platform 6.0 / Apache Kafka 2.6
New Features in Confluent Platform 6.0 / Apache Kafka 2.6New Features in Confluent Platform 6.0 / Apache Kafka 2.6
New Features in Confluent Platform 6.0 / Apache Kafka 2.6
Kai Wähner
 
Reference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to KubernetesReference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to Kubernetes
Rakesh Gujjarlapudi
 
Enabling Microservices Frameworks to Solve Business Problems
Enabling Microservices Frameworks to Solve  Business ProblemsEnabling Microservices Frameworks to Solve  Business Problems
Enabling Microservices Frameworks to Solve Business Problems
Ken Owens
 
Au delà des brokers, un tour de l’environnement Kafka | Florent Ramière
Au delà des brokers, un tour de l’environnement Kafka | Florent RamièreAu delà des brokers, un tour de l’environnement Kafka | Florent Ramière
Au delà des brokers, un tour de l’environnement Kafka | Florent Ramière
confluent
 
Connecting kafka message systems with scylla
Connecting kafka message systems with scylla   Connecting kafka message systems with scylla
Connecting kafka message systems with scylla
Maheedhar Gunturu
 
Citi Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid CloudCiti Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid Cloud
confluent
 
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & PartitioningApache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Guido Schmutz
 
Event Streaming Architectures with Confluent and ScyllaDB
Event Streaming Architectures with Confluent and ScyllaDBEvent Streaming Architectures with Confluent and ScyllaDB
Event Streaming Architectures with Confluent and ScyllaDB
ScyllaDB
 
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Tammy Bednar
 
Architectures with Windows Azure
Architectures with Windows AzureArchitectures with Windows Azure
Architectures with Windows Azure
Damir Dobric
 
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Kai Wähner
 
Kafka Connect & Streams - the ecosystem around Kafka
Kafka Connect & Streams - the ecosystem around KafkaKafka Connect & Streams - the ecosystem around Kafka
Kafka Connect & Streams - the ecosystem around Kafka
Guido Schmutz
 
Bee brief-intro-q42016
Bee brief-intro-q42016Bee brief-intro-q42016
Bee brief-intro-q42016
wahyu prayudo
 
Confluent Tech Talk Korea
Confluent Tech Talk KoreaConfluent Tech Talk Korea
Confluent Tech Talk Korea
confluent
 
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LMESet your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
confluent
 
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
confluent
 
Developing Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache KafkaDeveloping Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache Kafka
Joe Stein
 
Elastically Scaling Kafka Using Confluent
Elastically Scaling Kafka Using ConfluentElastically Scaling Kafka Using Confluent
Elastically Scaling Kafka Using Confluent
confluent
 
NaradaBrokering Grid Messaging and Applications as Web Services
NaradaBrokering Grid Messaging and Applications as Web ServicesNaradaBrokering Grid Messaging and Applications as Web Services
NaradaBrokering Grid Messaging and Applications as Web ServicesVideoguy
 
NaradaBrokering Grid Messaging and Applications as Web Services
NaradaBrokering Grid Messaging and Applications as Web ServicesNaradaBrokering Grid Messaging and Applications as Web Services
NaradaBrokering Grid Messaging and Applications as Web ServicesVideoguy
 

Similar to Implementing Domain Events with Kafka (20)

New Features in Confluent Platform 6.0 / Apache Kafka 2.6
New Features in Confluent Platform 6.0 / Apache Kafka 2.6New Features in Confluent Platform 6.0 / Apache Kafka 2.6
New Features in Confluent Platform 6.0 / Apache Kafka 2.6
 
Reference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to KubernetesReference architectures shows a microservices deployed to Kubernetes
Reference architectures shows a microservices deployed to Kubernetes
 
Enabling Microservices Frameworks to Solve Business Problems
Enabling Microservices Frameworks to Solve  Business ProblemsEnabling Microservices Frameworks to Solve  Business Problems
Enabling Microservices Frameworks to Solve Business Problems
 
Au delà des brokers, un tour de l’environnement Kafka | Florent Ramière
Au delà des brokers, un tour de l’environnement Kafka | Florent RamièreAu delà des brokers, un tour de l’environnement Kafka | Florent Ramière
Au delà des brokers, un tour de l’environnement Kafka | Florent Ramière
 
Connecting kafka message systems with scylla
Connecting kafka message systems with scylla   Connecting kafka message systems with scylla
Connecting kafka message systems with scylla
 
Citi Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid CloudCiti Tech Talk: Hybrid Cloud
Citi Tech Talk: Hybrid Cloud
 
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & PartitioningApache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
 
Event Streaming Architectures with Confluent and ScyllaDB
Event Streaming Architectures with Confluent and ScyllaDBEvent Streaming Architectures with Confluent and ScyllaDB
Event Streaming Architectures with Confluent and ScyllaDB
 
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
Database@Home : Data Driven Apps - Data-driven Microservices Architecture wit...
 
Architectures with Windows Azure
Architectures with Windows AzureArchitectures with Windows Azure
Architectures with Windows Azure
 
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
 
Kafka Connect & Streams - the ecosystem around Kafka
Kafka Connect & Streams - the ecosystem around KafkaKafka Connect & Streams - the ecosystem around Kafka
Kafka Connect & Streams - the ecosystem around Kafka
 
Bee brief-intro-q42016
Bee brief-intro-q42016Bee brief-intro-q42016
Bee brief-intro-q42016
 
Confluent Tech Talk Korea
Confluent Tech Talk KoreaConfluent Tech Talk Korea
Confluent Tech Talk Korea
 
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LMESet your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
 
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
Modern Cloud-Native Streaming Platforms: Event Streaming Microservices with A...
 
Developing Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache KafkaDeveloping Realtime Data Pipelines With Apache Kafka
Developing Realtime Data Pipelines With Apache Kafka
 
Elastically Scaling Kafka Using Confluent
Elastically Scaling Kafka Using ConfluentElastically Scaling Kafka Using Confluent
Elastically Scaling Kafka Using Confluent
 
NaradaBrokering Grid Messaging and Applications as Web Services
NaradaBrokering Grid Messaging and Applications as Web ServicesNaradaBrokering Grid Messaging and Applications as Web Services
NaradaBrokering Grid Messaging and Applications as Web Services
 
NaradaBrokering Grid Messaging and Applications as Web Services
NaradaBrokering Grid Messaging and Applications as Web ServicesNaradaBrokering Grid Messaging and Applications as Web Services
NaradaBrokering Grid Messaging and Applications as Web Services
 

Recently uploaded

AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 

Recently uploaded (20)

AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 

Implementing Domain Events with Kafka

  • 1. Implementing Domain Events with Kafka Devtalks How DDD and Kafka help in integrating microservices Bucharest, 12th of June 2020 ,
  • 2. Agenda 2 Challenges in integrating microservices What is a Domain Event? Implementation patterns for Domain Events Kafka Delivery Guarantees & Configurations
  • 3. Microservices benefits • Agility in development • Better understanding of the architecture • Resilience in production • Independent scalability of microservices • Independent deployment of microservices • Fault tolerance (failures in a microservice can be isolated from other microservices) How can these benefits could be achieved? ✓ Ensuring microservice autonomy ✓ Defining explicit contracts 3
  • 4. Synchronous Integration between Microservices ▪ Temporal Coupling ▪ Behavioral Coupling* The services are not autonomous Complex and unreliable compensation logic Circuit breaker, timeouts, retries etc. are of limited use *Reference: http://iansrobinson.com/2009/04/27/temporal-and-behavioural-coupling/ 4
  • 5. Introduction to DDD ▪ Strategic Design: ✓ bounded contexts ✓ context map ▪ Tactical Design: ✓ entities ✓ values ✓ aggregates ✓ aggregate roots ✓ Repositories ✓ services ✓ domain events ✓ application services 5 Reference: Evans, Eric. Domain-Driven Design: Tackling Complexity in the Heart of Software. Boston: Addison-Wesley, 2003, Vernon, Vaughn. Implementing Domain-Driven Design. Boston: Addison- Wesley, 2013.
  • 6. Microservices Design Rules 1 microservice = 1 bounded context = 1 deployment unit 1 operation = 1 transaction = 1 aggregate (modify in one transaction only one aggregate instance) Prefer asynchronous communication between microservices over synchronous request/reply integration ➔ integration based on domain events 6
  • 7. Domain Events • An event captures the changes in the state of a single aggregate • Events are immutable • They get published by the aggregates and contain the associated aggregate root id • Each event should have a unique id that could be used for de-duplication 7
  • 8. Integration Rules between Bounded Contexts ▪ Via a publish/subscriber messaging infrastructure ▪ The bounded contexts interested in the data maintained by other bounded contexts subscribe to the relevant events ▪ Integration via events is applicable also between different aggregate instances from the same bounded context 8 ➔ Transactional Consistency within aggregate boundaries ➔ Eventual Consistency between different bounded contexts and between different aggregate instances
  • 9. µ Service µ Service µ Service µ Service Event Bus REST/SOAP REST/SOAP REST/SOAP REST/SOAP UI/ API Gateway Data DataDataData Microservices Architecture based on DDD Decomposing application into loosely coupled services: - Explicit contract/ interface - Boundary alignment with business capabilities - Asynchronous communication between microservices - Microservices have their own storage (they are the authoritative source of data for their domain) 1 2 3 4 1 2 3 4 9
  • 10. Main use cases for domain events 10 Notifications other bounded contexts need to react to Data replication over events between bounded contexts CQRS (in the same bounded context)
  • 11. Messaging requirements in view of DDD ▪ Support for publish/subscriber pattern ▪ Support for competing consumers pattern ▪ Persistence and Durability ▪ At-least-once message delivery ▪ Partial message ordering (per aggregate) 11
  • 12. Kafka Logical Architecture 12 Replication + Fault Tolerance + Partitioning + Elastic Scaling Single-Leader System (all producers/consumers publish/fetch data to/from leaders ) CP in terms of CAP theorem for both write and read operations Confluent Platform 5.4 introduces Follower Fetching, Observers, and Replica Placement ➔ Fetching data from asynchronous replicas ➔ AP for read operations Availability ZoneAvailability Zone Broker B1 – Leader for partition 1, follower for partitions 3 and 4 Broker B2 – Leader for 2, follower for 1 and 4 Topic-partition1 Broker B3 – Leader for 3, follower for 1 and 2 Broker B4– Leader for 4, follower for 2 and 3 Topic-partition2 Topic-partition3 Topic-partition4 Topic-partition1 Topic-partition1 fetch fetch Topic-partition2 Topic-partition2 fetchfetch Topic-partition3 Topic-partition3 fetch fetch Topic-partition4 Topic-partition4 fetchfetch Producer/ Consumer Initial ISR: {B1, B2, B3} Initial ISR: {B2, B3, B4} Initial ISR: {B1, B3, B4} Initial ISR: {B1, B2, B4}
  • 13. Kafka Broker Configurations min.insync.replicas: should be set to a value greater than 1 replica.lag.time.max.ms unclean.leader.election.enable: should be false broker.rack: should reflect data centers, regions or availability zones where brokers are placed replica.selector.class (since Confluent 5.4): used by the broker to find the preferred read replica. By default it returns partition leaders. 13 * Reference: https://docs.confluent.io/current/installation/configuration/broker-configs.html
  • 14. Kafka Offsets 14 0 1 2 cp up hw ...lc end Begin Offset Last Commited Offset of a Consumer Consumer s Current Position Undereplicated Partition from a follower non-ISR broker High Watermark (last index replicated to all ISR) Messages published with acks 0 or 1 and not yet replicated Consumer s batch of messages
  • 15. How to choose the number of topics/partitions ▪ Number of partitions = producer throughput/ consumer throughput ▪ limit the number of partitions per broker to 100 x b x r, Where: b is the number of brokers in a Kafka cluster r is the replication factor Why? “Kafka broker uses only a single thread to replicate data from another broker, for all partitions that share replicas between the two brokers. (…)replicating 1000 partitions from one broker to another can add about 20 ms latency, which implies that the end-to-end latency is at least 20 ms.”* 15 * Reference: https://www.confluent.io/blog/how-choose-number-topics-partitions-kafka-cluster/
  • 16. How Kafka addresses DDD messaging requirements Support for publish/subscribers pattern ➔ topics Support for competing consumers pattern ➔ consumer groups Persistence and Durability ➔ replication factors, ISR, retention policies At-least-once message delivery ➔ acks (on producer-side), default behavior of consumers (when auto commit is enabled) Partial message ordering (per aggregate) ➔ partitions 16
  • 17. Application Requirements in View of DDD ▪ Domain events are self-contained messages (events capture the state changes in domain entities and provide decision support for subscribers) ▪ Domain events are part of a microservice's public API/contract ▪ One topic per aggregate type ▪ Partitioning by aggregate/entity ID ▪ Transactional semantics when publishing events ▪ Events deduplication on subscriber-side for achieving exactly-once delivery semantics 17
  • 18. Aggregate Processing 18 Client Application Service Aggregate Root Entity Repository KafkaProducer remote operation Aggregate root method Entity method Publish event: event type, root id, event id, aggregate root state change, entity state change Find aggregate State change State change Save aggregate Bounded Context
  • 19. Transactional Publishing Patterns 19 Client Application Service Aggregate Root Repository Event Publisher remote operation Aggregate root method Find aggregate local transaction Bounded Context Events Table (same DB) KafkaProducer State change Polling Publisher send Update offset loop
  • 20. Kafka Producer Properties props = new Properties(); props.put("bootstrap.servers", "localhost:9092"); props.put("acks", "all"); props.put("key.serializer", "io.confluent.kafka.serializers.KafkaAvroSerializer"); props.put("value.serializer", "io.confluent.kafka.serializers.KafkaAvroSerializer"); …. Producer<String, String> producer = new KafkaProducer<>(props); …. Future<RecordMetadata> metadata = producer.send(new ProducerRecord<String, String>("my-topic", key, value)); …. producer.close() 20
  • 21. Kafka Producer Configurations acks = all retries = 2147483647. delivery.timeout.ms enable.idempotence = true. max.in.flight.requests.per.connection = 1. 21 * Reference: https://docs.confluent.io/current/installation/configuration/producer-configs.html
  • 22. Kafka Consumer try { while (true) { ConsumerRecords<String, String> records = consumer.poll(MAX_VALUE); for (ConsumerRecord<String, String> record : records) { System.out.println(record.offset() + “: ” + record.value()); } try { //saving new offsets if enable.auto.commit = false } catch (CommitFailedException e) { // application specific failure handling } } } catch (WakeupException e) { // ignore for shutdown } finally { consumer.close(); } 22 Up to max.poll.records max.poll.interval.ms > max.poll.records * record processing time Commit if enable.auto.commit = true and the interval between current poll and last commit >= auto.commit.interval.ms
  • 23. Kafka Consumer Configurations ▪ group.id ▪ heartbeat.interval.ms & session.timeout.ms ▪ enable.auto.commit & auto.commit.interval.ms ▪ isolation.level ▪ max.poll.interval.ms ▪ max.poll.records ▪ client.rack (since Confluent 5.4; if the partition is rack aware and the replica selector is set, pick a “preferred read replica”) 23
  • 24. Exactly-once Stateful Processing 24 Kafka Broker(s) Kafka Consumer Aggregate Root Repository Offset Manager Poll for events Aggregate root method Save aggregate events local transaction Bounded Context Offsets Table Aggregate State Table Select offsets State change Update Offset Same Database loop
  • 25. Avro Consumers & Producers 25 Schema Registry Kafka Producer Consumer Send Avro content + Schema id Query schema id by schema content Get writer s schema by id Read avro content + schema Id Apply schema evolution
  • 26. Avro • Kafka records can have a Key and a Value and both can have a schema. • There is a compatibility level (BACKWARDS, FORWARDS, FULL, NONE) setting for the Schema Registry and an individual subject. Versions are also managed per subject • Backward compatibility = consumers coded with a newer schema can read messages written with older schema. • Forward compatibility = consumers coded with a older schema can read messages written with a newer schema. • Full compatibility = a new schema version is both backward and forward compatible. • None • Avro schema evolution is an automatic transformation of messages from the schema used by producers to write into the Kafka log to schema used by consumer to read them. The transformation occurs at consuming time in Avro Deserializer. 26 Change Type Order of releasing into production Backward Compatible Consumers, Producers Forward Compatible Producers, Consumers (after they finish reading old messages) Fully Compatible Order doesn’t matter None Coordinated
  • 27. Subject Name Strategy • A DDD aggregate could publish multiple event types, each capturing a distinct business intent • For maintaining the correct event order all the events will be published in the same topic (using aggregate id as message key) • Multiple event types require multiple schemas (one for each event type that could be published in the same topic) • Producer-side configs: • schema registry url • key.subject.name.strategy (which defines how to construct the subject name for message keys) = TopicNameStrategy, RecordNameStrategy or TopicRecordNameStrategy • value.subject.name.strategy (how to construct the subject name for message values) = TopicNameStrategy, RecordNameStrategy or TopicRecordNameStrategy • Consumer-side configs: • specific.avro.reader = true (or otherwise you get Avro GenericRecord) 27
  • 28. Conclusions Domain Driven Design not only helps in decomposing a system into microservices aligned with business capabilities, but also offers essential lessons on: ✓ how to achieve resilience ✓ how to achieve scalability by decoupling microservices using domain events 28