SlideShare a Scribd company logo
Microservices Integration Patterns with Kafka
Kasun Indrasiri
Director - Integration Architecture,
WSO2
Bay Area Apache Kafka Meetup
@ Lyft HQ, San Francisco
● Microservices Integration/composition?
● Microservices Composition Patterns
○ Active/Synchronous Composition
○ Reactive Composition
● Kafka for building Reactive Composition.
● Hybrid of active and reactive composition.
Overview
Rise of Cloud Native
Applications
Integrating
Microservices and
Cloud Native Apps
Integration is essential to build
any real world use case with
cloud native apps.
● APIs:
○ Commands - Actions, synchronous
○ Queries - Request for information, no state change, synchronous
● Events: Facts and notifications, asynchronous
● Streams: A sequence of events/data elements made available
over time
Microservices Integration/Composition
How services can interact over the network?
Active Composition/Orchestration Pattern
Synchronous/request-response communication
Consumer 1
API Service P API Service Q API Service R API Service S
Consumers
Consumer 2 Consumer 3
μ Service A
Proprietary
& Legacy
Systems
Web API /
SaaS
API Services/
Edge Services
Composite Service/
Integration Services
Core Services/
Atomic Services μ Service I
μ Service H
μ Service J
μ Service E
μ Service C
μ Service D
μ Service G
μ Service B
μ Service F
API
Management
● RESTful Services
● gRPC/HTTP2
● GraphQL
● WebSockets
● Thrift
Active Composition/Orchestration Pattern
Synchronous/request-response communication
Reactive Composition/Choreography Pattern
μ Service A μ Service B μ Service C
Event Bus
Application
Asynchronous event-driven communication
Produce Consume
Produce Consume
Produce Consume
Produce Consume
● Kafka
● AMQP
● JMS
Reactive Composition/Choreography Pattern
Asynchronous event-driven communication
Kafka in a nutshell
Source: “Microservices for Enterprise” https://goo.gl/p3rWF3
● Consumers from different
consumer groups subscribe
to the same topic.
● Consumers of a given CG
can only consume from one
partition.
Reactive Composition with Kafka
Publisher-subscriber
Source: “Microservices for Enterprise” https://goo.gl/p3rWF3
● Single consumer group and a
consumer per each partition.
● Polling and sequential
processing of consumer
records using offset.
Reactive Composition with Kafka
Single Consumer/Queuing
Source: “Microservices for Enterprise” https://goo.gl/p3rWF3
topic
Delivery Semantics: Exactly-Once/Atomic Broadcast
Reactive Composition with Kafka
● You can publish messages and they will be delivered one time
exactly by one or more receiving application.
● Producer side
○ Producer writes to the log but fails to get the ack. over network.
● Consumer side
○ Consumer consumes message from the log but fails before
updating its offset value.
Source: https://medium.com/@jaykreps/exactly-once-support-in-apache-kafka-55e1fdd0a35f
Delivery Semantics: Exactly-Once/Atomic Broadcast
Reactive Composition with Kafka
● Producer side
○ Idempotence : Producers can retry until it is successful
○ Kafka will detect the duplicates and remove them
● Consumer side
○ Store the offsets in the same DB as the derived state and update
both in a transaction.
○ Write both state updates and offsets together in a way that is
idempotent.
Source: https://medium.com/@jaykreps/exactly-once-support-in-apache-kafka-55e1fdd0a35f
Event Sourcing
● Persist each state changing events of an entity as a sequence
of immutable events.
● All such events are stored in an event bus and consumers can
derive the state by processing a sequence of events.
Shipping
● Stream Processing in Microservices
○ Services that execute a business logic against a sequence of
events/data elements made available over time.
● Kafka Streams : a client library for building stream processing
on top of Kafka.
Reactive Composition with Kafka
Kafka Streams
● Command Query Responsibility Segregation.
● Split the common data model into query and command
models.
● Kafka Stream - Interactive queries.
CQRS
Command
Source:
https://www.confluent.io/blog/event-sourcing-cqrs-stream-processing-apache-kafka-whats-connection/
Query
● Kafka does not look at your data but you need consistent
across your usage.
○ Avro, ProtoBuf, JSON, XML, ASN.1
○ Avro preferred schema for Kafka, Kafka schema registry
● Schema in practice
○ Associate an Avro schema with a topic.
○ Declare requirements for data that is produced into the topic
○ Provides the instructions on how to interpret data read from the topic
Using Schemas - Avro and Schema Registry
● A tool for scalably and reliably streaming data between
Apache Kafka and other data systems.
Reactive Composition with Kafka
Kafka Connect
Source: https://www.confluent.io/blog/announcing-kafka-connect-building-large-scale-low-latency-data-pipelines/
Kafka, Kafka Connect and Kafka Streams
Source: https://www.confluent.io/blog/hello-world-kafka-connect-kafka-streams/
Active
or
Reactive?
● Active Composition
○ Ideal for interactive services
○ Service are NOT autonomous
● Reactive Composition
○ Ideal for asynchronous
interactions
○ Composition logic is opaque
Hybrid of Active and Reactive Composition
Consumer 1
API Service P API Service Q API Service R API Service S
Consumers
Consumer 2 Consumer 3
μ Service A
Event Bus
Proprietary
& Legacy
Systems
Web API /
SaaS
API Services/
Edge Services
Composite Service/
Integration Services
Core Services/
Atomic Services μ Service I
μ Service H
μ Service J
μ Service E
μ Service C
μ Service D
μ Service G
μ Service B
API
Management
● Create a queryable materialized view using Kafka Streams or
a database with Kafka Connect.
Hybrid composition
Bridging request-response and event driven messaging
Source: https://github.com/confluentinc/kafka-streams-examples/tree/5.0.0-post/src/main/java/io/confluent/examples/streams/microservices
● A queryable materialized view using Kafka Streams’
interactive queries.
Hybrid composition
Bridging request-response and event driven messaging
Implementation Technologies
● Java
○ All of the Kafka, Streams and Connect APIs are supported.
○ Confluent microservices example.
● Go, Python, .NET
● Ballerina (ballerina.io)
○ Cloud-native programming languages that makes it easy to write
microservices that integrate APIs.
https://ballerina.io/learn/by-guide/messaging-with-kafka/
● Integration Frameworks: Apache Camel, Spring Boot, WSO2
Integrator etc.
THANK YOU
Kasun Indrasiri
kasun@apache.org

More Related Content

PDF
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
PDF
When NOT to use Apache Kafka?
PPTX
Microservices Part 3 Service Mesh and Kafka
PDF
Event-Driven Architecture (EDA)
ODP
Stream processing using Kafka
PDF
What Is ELK Stack | ELK Tutorial For Beginners | Elasticsearch Kibana | ELK S...
PPTX
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
PDF
The Rise Of Event Streaming – Why Apache Kafka Changes Everything
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
When NOT to use Apache Kafka?
Microservices Part 3 Service Mesh and Kafka
Event-Driven Architecture (EDA)
Stream processing using Kafka
What Is ELK Stack | ELK Tutorial For Beginners | Elasticsearch Kibana | ELK S...
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
The Rise Of Event Streaming – Why Apache Kafka Changes Everything

What's hot (20)

PPTX
Azure API Management
PPTX
Microservices in the Apache Kafka Ecosystem
PPTX
Splunk Overview
PDF
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
PPTX
Data Streaming with Apache Kafka & MongoDB
PPTX
Mainframe Modernization with Precisely and Microsoft Azure
PDF
Apache Kafka Architecture & Fundamentals Explained
PDF
Fundamentals of Apache Kafka
PDF
An Introduction to Apache Kafka
PDF
Design patterns for microservice architecture
PPSX
Event Sourcing & CQRS, Kafka, Rabbit MQ
PDF
Event Driven Microservices with Spring Cloud Stream #jjug_ccc #ccc_ab3
PDF
Benefits of Stream Processing and Apache Kafka Use Cases
PDF
Kafka for Real-Time Replication between Edge and Hybrid Cloud
PDF
Stream Processing with Apache Kafka and .NET
PDF
The Architecture of an API Platform
PDF
S4HANA Migration Overview
PPTX
Splunk Architecture
PPTX
Guide to an API-first Strategy
PDF
Introduction to Kafka Streams
Azure API Management
Microservices in the Apache Kafka Ecosystem
Splunk Overview
Set your Data in Motion with Confluent & Apache Kafka Tech Talk Series LME
Data Streaming with Apache Kafka & MongoDB
Mainframe Modernization with Precisely and Microsoft Azure
Apache Kafka Architecture & Fundamentals Explained
Fundamentals of Apache Kafka
An Introduction to Apache Kafka
Design patterns for microservice architecture
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Driven Microservices with Spring Cloud Stream #jjug_ccc #ccc_ab3
Benefits of Stream Processing and Apache Kafka Use Cases
Kafka for Real-Time Replication between Edge and Hybrid Cloud
Stream Processing with Apache Kafka and .NET
The Architecture of an API Platform
S4HANA Migration Overview
Splunk Architecture
Guide to an API-first Strategy
Introduction to Kafka Streams
Ad

Similar to Microservices Integration Patterns with Kafka (20)

PPTX
A Short Presentation on Kafka
PDF
Day in the life event-driven workshop
PPTX
Connecting kafka message systems with scylla
PDF
Budapest Data/ML - Building Modern Data Streaming Apps with NiFi, Flink and K...
PDF
Confluent Tech Talk Korea
PDF
Build Real-Time Streaming ETL Pipelines With Akka Streams, Alpakka And Apache...
PDF
PortoTechHub - Hail Hydrate! From Stream to Lake with Apache Pulsar and Friends
PDF
Streaming with Spring Cloud Stream and Apache Kafka - Soby Chacko
PDF
PDF
Building Microservices with Apache Kafka
PDF
Spring 5 Webflux - Advances in Java 2018
PDF
PDF
Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...
PPTX
Apache frameworks for Big and Fast Data
PDF
Cloud lunch and learn real-time streaming in azure
PDF
Microservices with Spring 5 Webflux - jProfessionals
PDF
Integration Microservices
PPTX
Kafka.pptx (uploaded from MyFiles SomnathDeb_PC)
PPTX
Kafka Streams for Java enthusiasts
PDF
Building Streaming Data Applications Using Apache Kafka
A Short Presentation on Kafka
Day in the life event-driven workshop
Connecting kafka message systems with scylla
Budapest Data/ML - Building Modern Data Streaming Apps with NiFi, Flink and K...
Confluent Tech Talk Korea
Build Real-Time Streaming ETL Pipelines With Akka Streams, Alpakka And Apache...
PortoTechHub - Hail Hydrate! From Stream to Lake with Apache Pulsar and Friends
Streaming with Spring Cloud Stream and Apache Kafka - Soby Chacko
Building Microservices with Apache Kafka
Spring 5 Webflux - Advances in Java 2018
Kafka Cluster Federation at Uber (Yupeng Fui & Xiaoman Dong, Uber) Kafka Summ...
Apache frameworks for Big and Fast Data
Cloud lunch and learn real-time streaming in azure
Microservices with Spring 5 Webflux - jProfessionals
Integration Microservices
Kafka.pptx (uploaded from MyFiles SomnathDeb_PC)
Kafka Streams for Java enthusiasts
Building Streaming Data Applications Using Apache Kafka
Ad

More from Kasun Indrasiri (16)

PPTX
Adaptive and Iterative Integration for Microservices and Cloud Native Archite...
PDF
Microservices for Enterprises
PDF
Bridging Microservices, APIs and Integration
PPTX
The Role of Enterprise Integration in Digital Transformation
PDF
Deep-dive into WSO2 ESB 5.0
PDF
Microintegration
PDF
Microservices in Practice
PPTX
Reactive Programming in Java 8 with Rx-Java
PPT
WSO2-ESB - The backbone of Enterprise Integration
PPTX
Introduction to WSO2 Integration Platform
PPTX
WSO2 Gateway
PPTX
The Middleware technology that connects the enterprise
PDF
API, Integration, and SOA Convergence
PDF
The Past, Present and Future of Enterprise Integration
PPTX
WSO2 ESB - The Backbone of Integration
PPTX
Connected Retail
Adaptive and Iterative Integration for Microservices and Cloud Native Archite...
Microservices for Enterprises
Bridging Microservices, APIs and Integration
The Role of Enterprise Integration in Digital Transformation
Deep-dive into WSO2 ESB 5.0
Microintegration
Microservices in Practice
Reactive Programming in Java 8 with Rx-Java
WSO2-ESB - The backbone of Enterprise Integration
Introduction to WSO2 Integration Platform
WSO2 Gateway
The Middleware technology that connects the enterprise
API, Integration, and SOA Convergence
The Past, Present and Future of Enterprise Integration
WSO2 ESB - The Backbone of Integration
Connected Retail

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
System and Network Administration Chapter 2
PDF
Digital Strategies for Manufacturing Companies
Understanding Forklifts - TECH EHS Solution
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Softaken Excel to vCard Converter Software.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Reimagine Home Health with the Power of Agentic AI​
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Digital Systems & Binary Numbers (comprehensive )
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Computer Software and OS of computer science of grade 11.pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
System and Network Administration Chapter 2
Digital Strategies for Manufacturing Companies

Microservices Integration Patterns with Kafka

  • 1. Microservices Integration Patterns with Kafka Kasun Indrasiri Director - Integration Architecture, WSO2 Bay Area Apache Kafka Meetup @ Lyft HQ, San Francisco
  • 2. ● Microservices Integration/composition? ● Microservices Composition Patterns ○ Active/Synchronous Composition ○ Reactive Composition ● Kafka for building Reactive Composition. ● Hybrid of active and reactive composition. Overview
  • 3. Rise of Cloud Native Applications
  • 4. Integrating Microservices and Cloud Native Apps Integration is essential to build any real world use case with cloud native apps.
  • 5. ● APIs: ○ Commands - Actions, synchronous ○ Queries - Request for information, no state change, synchronous ● Events: Facts and notifications, asynchronous ● Streams: A sequence of events/data elements made available over time Microservices Integration/Composition How services can interact over the network?
  • 6. Active Composition/Orchestration Pattern Synchronous/request-response communication Consumer 1 API Service P API Service Q API Service R API Service S Consumers Consumer 2 Consumer 3 μ Service A Proprietary & Legacy Systems Web API / SaaS API Services/ Edge Services Composite Service/ Integration Services Core Services/ Atomic Services μ Service I μ Service H μ Service J μ Service E μ Service C μ Service D μ Service G μ Service B μ Service F API Management
  • 7. ● RESTful Services ● gRPC/HTTP2 ● GraphQL ● WebSockets ● Thrift Active Composition/Orchestration Pattern Synchronous/request-response communication
  • 8. Reactive Composition/Choreography Pattern μ Service A μ Service B μ Service C Event Bus Application Asynchronous event-driven communication Produce Consume Produce Consume Produce Consume Produce Consume
  • 9. ● Kafka ● AMQP ● JMS Reactive Composition/Choreography Pattern Asynchronous event-driven communication
  • 10. Kafka in a nutshell Source: “Microservices for Enterprise” https://goo.gl/p3rWF3
  • 11. ● Consumers from different consumer groups subscribe to the same topic. ● Consumers of a given CG can only consume from one partition. Reactive Composition with Kafka Publisher-subscriber Source: “Microservices for Enterprise” https://goo.gl/p3rWF3
  • 12. ● Single consumer group and a consumer per each partition. ● Polling and sequential processing of consumer records using offset. Reactive Composition with Kafka Single Consumer/Queuing Source: “Microservices for Enterprise” https://goo.gl/p3rWF3 topic
  • 13. Delivery Semantics: Exactly-Once/Atomic Broadcast Reactive Composition with Kafka ● You can publish messages and they will be delivered one time exactly by one or more receiving application. ● Producer side ○ Producer writes to the log but fails to get the ack. over network. ● Consumer side ○ Consumer consumes message from the log but fails before updating its offset value. Source: https://medium.com/@jaykreps/exactly-once-support-in-apache-kafka-55e1fdd0a35f
  • 14. Delivery Semantics: Exactly-Once/Atomic Broadcast Reactive Composition with Kafka ● Producer side ○ Idempotence : Producers can retry until it is successful ○ Kafka will detect the duplicates and remove them ● Consumer side ○ Store the offsets in the same DB as the derived state and update both in a transaction. ○ Write both state updates and offsets together in a way that is idempotent. Source: https://medium.com/@jaykreps/exactly-once-support-in-apache-kafka-55e1fdd0a35f
  • 15. Event Sourcing ● Persist each state changing events of an entity as a sequence of immutable events. ● All such events are stored in an event bus and consumers can derive the state by processing a sequence of events. Shipping
  • 16. ● Stream Processing in Microservices ○ Services that execute a business logic against a sequence of events/data elements made available over time. ● Kafka Streams : a client library for building stream processing on top of Kafka. Reactive Composition with Kafka Kafka Streams
  • 17. ● Command Query Responsibility Segregation. ● Split the common data model into query and command models. ● Kafka Stream - Interactive queries. CQRS Command Source: https://www.confluent.io/blog/event-sourcing-cqrs-stream-processing-apache-kafka-whats-connection/ Query
  • 18. ● Kafka does not look at your data but you need consistent across your usage. ○ Avro, ProtoBuf, JSON, XML, ASN.1 ○ Avro preferred schema for Kafka, Kafka schema registry ● Schema in practice ○ Associate an Avro schema with a topic. ○ Declare requirements for data that is produced into the topic ○ Provides the instructions on how to interpret data read from the topic Using Schemas - Avro and Schema Registry
  • 19. ● A tool for scalably and reliably streaming data between Apache Kafka and other data systems. Reactive Composition with Kafka Kafka Connect Source: https://www.confluent.io/blog/announcing-kafka-connect-building-large-scale-low-latency-data-pipelines/
  • 20. Kafka, Kafka Connect and Kafka Streams Source: https://www.confluent.io/blog/hello-world-kafka-connect-kafka-streams/
  • 21. Active or Reactive? ● Active Composition ○ Ideal for interactive services ○ Service are NOT autonomous ● Reactive Composition ○ Ideal for asynchronous interactions ○ Composition logic is opaque
  • 22. Hybrid of Active and Reactive Composition Consumer 1 API Service P API Service Q API Service R API Service S Consumers Consumer 2 Consumer 3 μ Service A Event Bus Proprietary & Legacy Systems Web API / SaaS API Services/ Edge Services Composite Service/ Integration Services Core Services/ Atomic Services μ Service I μ Service H μ Service J μ Service E μ Service C μ Service D μ Service G μ Service B API Management
  • 23. ● Create a queryable materialized view using Kafka Streams or a database with Kafka Connect. Hybrid composition Bridging request-response and event driven messaging Source: https://github.com/confluentinc/kafka-streams-examples/tree/5.0.0-post/src/main/java/io/confluent/examples/streams/microservices
  • 24. ● A queryable materialized view using Kafka Streams’ interactive queries. Hybrid composition Bridging request-response and event driven messaging
  • 25. Implementation Technologies ● Java ○ All of the Kafka, Streams and Connect APIs are supported. ○ Confluent microservices example. ● Go, Python, .NET ● Ballerina (ballerina.io) ○ Cloud-native programming languages that makes it easy to write microservices that integrate APIs. https://ballerina.io/learn/by-guide/messaging-with-kafka/ ● Integration Frameworks: Apache Camel, Spring Boot, WSO2 Integrator etc.