SlideShare a Scribd company logo
Classificatie: vertrouwelijk
Microservices in
real life – with
Apache Kafka,
Node & Dapr.io
Part 2
March 2022
Lucas Jellema
Architect & CTO AMIS | Conclusion
Classificatie: vertrouwelijk
Microservices in real life – with Node & Dapr.io
Founded in 1991 by students
from University of Twente –
Aircraft Maintenance Information
System (AMIS)
80 colleagues,
located in
Nieuwegein
the core of what we do:
working with Data.
partnering with peers
and companies in
several countries
Lucas Jellema (2002)
Cloud Solution Architect & CTO
lucas.jellema@amis.nl | technology.amis.nl | @lucasjellema | lucas-jellema
Classificatie: vertrouwelijk
Microservices in real life – with Node & Dapr.io
Data Engineering, Data Analytics
(& Data Science)
Data &
Application
Integration
web
applications
Internet of Things
cloud, DevOps, PaaS,
streaming, microservices,
Software Studio, database,
software engineering
Oracle, Microsoft Azure,
open source, Java, SQL,
NodeJS, Python,Kafka
React/Angular
Classificatie: vertrouwelijk
Microservices in real life – with Node & Dapr.io
Classificatie: Public
Publiek
Overview
• Part One (last week)
• Microservices recap
• Dapr.io – personal assistant for applications & distributed application runtime
• Handson with Dapr.io
• Quick Intro to programming in Node[.js]
• Handson Microservice implementation with Node and Dapr.io
• Part Two (today)
• Introduction of Apache Kafka (“Twitter for systems”)
• Asynchronous interactions through Apache Kafka – concepts, terminology
• Handson with Apache Kafka and Node
• Real world use cases and scenarios with Apache Kafka
• Handson Multi-microservice set up with Apache Kafka, Node and Dapr.io
Microservices in real life – with Node & Dapr.io
Classificatie: Public
Publiek
Assumed is
• A development environment with VS Code, Docker and Docker Composer,
the ability (permissions) to install software
• Knowledge of
• HTTP, REST, JSON
• Containers, Docker (and Kubernetes)
• Java or C#
• SQL and a database (MySQL or PostgreSQL or SQL Server)
• perhaps Message Broker/Event Queue (RabbitMQ?), Cache (Redis?)
• Cloud fundamentals
• Microservices concepts
Microservices in real life – with Node & Dapr.io
Classificatie: Public
Publiek
It would be so nice if I could
publish my ideas and actions,
accessible near instantly for
everyone who is interested
Heck, I do not even know these people
and they may not know me [personally]
– just my pearls of wisdom. And if they
are late to the party, they can also
check out the historic archives of my
eloquence
Without fretting about the numbers of
readers involved and whether they are
in the same time zone as me and online
when I publish my messages – and
which device they use
Classificatie: Public
Publiek
It would be so nice if I could
publish my ideas and actions,
accessible near instantly for
everyone who is interested
Heck, I do not even know these people
and they may not know me [personally]
– just my pearls of wisdom. And if they
are late to the party, they can also
check out the historic archives of my
eloquence
Without fretting about the numbers of
readers involved and whether they are
in the same time zone as me and online
when I publish my messages – and
which device they use
Classificatie: Public
Publiek
It would be so nice if I could
publish my ideas and actions,
accessible near instantly for
everyone who is interested
Heck, I do not even know these people
and they may not know me [personally]
– just my pearls of wisdom. And if they
are late to the party, they can also
check out the historic archives of my
eloquence
Without fretting about the numbers of
readers involved and whether they are
in the same time zone as me and online
when I publish my messages – and
which device they use
Classificatie: Public
Publiek
• Decoupled communication
• 0, 1 or many followers
• Scalable number of messages (and parties)
• Reliable (mostly available, few messages lost)
• Full history
• Open: cross device, cross location
• Not Sub-second, near real-time fast
• Rate limited (#messages/minute)
• Size limited (140-280 characters)
• Format limited (text)
• Not for private interactions
• Not (really) for programmatic use
Classificatie: Public
Publiek
What does the Twitter for System Driven Event Interaction
look like?
Microservices & Apache Kafka - 24 maart 2021
• Decoupled communication – organized per topic
• 0, 1 or many Consumers per Topic
• Scalable number of messages (and parties)
• Reliable (distributed)
• Full history
• Open: libraries in many technologies & REST APIs
Classificatie: Public
Publiek
What does the Twitter for System Driven Event Interaction
look like?
Microservices & Apache Kafka - 24 maart 2021
• Decoupled communication – organized per topic
• 0, 1 or many Consumers per Topic
• Scalable number of messages (and parties)
• Reliable (distributed)
• Full history
• Open: libraries in many technologies & REST APIs
• Near real-time fast
• No Rate Limit
• No enforced size limit
• Anything goes (it’s all byte[])
• On premises or in cloud, private or trusted
• Very much for programmatic use
Classificatie: Public
Publiek
Events
Producers
Consumers
Robust, QoS, Scalable,
Fast,
History Retention
Order preserved
Containerized/Cloud-
enabled
Open
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Messaging as we know it
• JMS, IBM MQ, MS MQ, RabbitMQ, MQTT, XMPP, WebSockets, Apache
ActiveMQ, …
• Challenges
• Costs
• Scalability (size and speed)
• (lack of) Distribution (and therefore availability)
• Complexity of infrastructure
• Message delivery guarantees (reliability)
• Lack of technology openness
• Deal with temporarily offline consumers
• Retain history
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Introducing Apache Kafka
• ..- 2010 – creation at Linkedin
• Message Bus | Event Broker
• High volume, low latency, highly reliable, cross technology
• Scalable, distributed, strict message ordering, ….
• 2011/2012 – open source under the Apache Incubator/ Top Project
• Kafka is used by many large corporations:
• Walmart, Cisco, Netflix, PayPal, LinkedIn, eBay, Spotify, Uber, Sift
Science, Zalando, The New York Times, Airbnb, Coursera, ING Bank,…
• … and embraced by many software vendors & cloud providers
• Commercial backing by and Enterprise support from Confluent
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Producers
Consumers
tcp
tcp
Microservices & Apache Kafka - 24 maart 2021
Client polls Event
Broker for messages
Classificatie: Public
Publiek
Producers
Consumers
Topic
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Kafka terminology
• Topic
• Message
• == ByteArray
• Broker
• Producer
• Consumer
• Offset
Producer Consumer
Topic
Broker
Key
Value
Time
Message
Microservices & Apache Kafka - 24 maart 2021
offset (for a specific consumer)
Classificatie: Public
Publiek
Producers
Consumers
Topic
Broker
Key
Value
Time
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Consuming
• Messages are available to consumers only when they have been committed
by the producer
• Kafka does not push
• Unlike JMS
• Read does not destroy
• Unlike JMS Topic
• (some | much | all) History available
• Offline consumers can catch up
• Consumers can re-consume from the past (just move offset)
• Delivery Guarantees
• Ordering maintained
• At-least-once (per consumer) by default; at-most-once and exactly-once
can be implemented
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
The company bulletin board
Microservices & Apache Kafka - 24 maart 2021
!
!!
“@#”
!
!
!!
Classificatie: Public
Publiek
The company bulletin board
Microservices & Apache Kafka - 24 maart 2021
!
!
!!
“@#$”
€
$
¥ ₤ ₨
Classificatie: Public
Publiek
Producers
Consumers
Topic
Broker
Key
Value
Time
Microservices & Apache Kafka - 24 maart 2021
Message
Log
Classificatie: Public
Publiek
Producers
Consumers
Topic
Broker
tcp
tcp
Microservices & Apache Kafka - 24 maart 2021
Cluster
Classificatie: Public
Publiek
Producers
Consumers
Topic
Broker
tcp
tcp
Consumer Group
Partition
Microservices & Apache Kafka - 24 maart 2021
Cluster
Partition Log
Replica
Classificatie: Public
Publiek
Consumers
Topic
Broker
Consumer Group
tition
Microservices & Apache Kafka - 24 maart 2021
Cluster
Consumer Group
• each consumer group consumes all
messages (once)
• each consumer in a group consumes
from one or more partitions (no partition
is consumed by more than one
consumer in a group)
• when more consumers in a group than
partitions in the topic, some consumers
get no messages
• when consumers disappear from a
group, their partition(s) are reassigned
to other consumers in the group
Classificatie: Public
Publiek
What’s so special?
• Durable transactions
• Scalable
• High volume
• High speed
• Parallel processing
• Available
• Distributed
• Open
• Quick start
• Free (no license costs)
• “Self Fulfilling Prophecy” leading to “de facto standard”
(positive feedback loop feeding from buzz around Kafka)
• Eco system, tools/libraries/resources, cloud services
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Some Kafka Use Cases
• Connected Cars, Manufacturing, Mobility, Gaming, Betting
• Tesla: Processing and analyzing the data from their vehicles, smart grids,
and factories and integrating with the rest of the IT backend services in real-
time is a crucial piece of Tesla’s success
Microservices in real life – with Node & Dapr.io
https://kai-waehner.medium.com/when-not-to-use-apache-kafka-a35345226a9f
Classificatie: Public
Publiek
Some Kafka Use Cases
• Connected Cars, Manufacturing, Mobility, Gaming, Betting
• Regulatory compliance and zero data loss are crucial.
• transactionally safe data replication
Microservices in real life – with Node & Dapr.io
https://kai-waehner.medium.com/when-not-to-use-apache-kafka-a35345226a9f
Classificatie: Public
Publiek
Some Kafka Use Cases
• Connected Cars, Manufacturing, Mobility, Gaming, Betting
• Royal Caribbean: Each cruise ship has a Kafka cluster running locally for
use cases such as payment processing, loyalty information, customer
recommendations, etc. Sync with shore when entering a port.
Microservices in real life – with Node & Dapr.io
https://kai-waehner.medium.com/when-not-to-use-apache-kafka-a35345226a9f
Classificatie: Public
Publiek
Quick Demo – Apache Kafka through Kafka Console
• Show interaction at the most basic level
• Broker
• Topic
• partition
• Produce Message
• Consume Message
• Consumer Group
Microservices & Apache Kafka - 24 maart 2021
Docker
Compose
Browser
Laptop
28042
9092
localhost
kafka
Classificatie: Public
Publiek
Lab: First steps with Apache Kafka
• Using Kafka Console
• Create a topic
• Publish messages to topic
• Using Kafka Console
• Consume messages from topic
• Work with Apache Kafka HQ GUI to
• inspect the Kafka Cluster
• produce additional messages
• consume message from a special Consumer Group
Microservices & Apache Kafka - 24 maart 2021
Docker
Compose
Browser
Laptop
28042
9092
localhost
kafka
Lab Resources: https://github.com/lucasjellema/fontys-2022-microservices-kafka-dapr
Classificatie: Public
Publiek
Lab Environment
Microservices & Apache Kafka - 24 maart 2021
Docker
Compose
Browser
Laptop
28042
9094
9093
9092
2181
28044
localhost
kafka
Lab Resources: https://github.com/lucasjellema/fontys-2022-microservices-kafka-dapr
Classificatie: Public
Publiek
Partly Clouded Lab Environment
Microservices & Apache Kafka - 24 maart 2021
Browser
Laptop
2181
localhost
CloudKarafka
Console
Lab Resources: -
www.cloudkarafka.com/plans.html
Classificatie: Public
Publiek
Agenda -
• Part One (last week – microservices, Node, Dapr.io)
• Part Two (today)
• Introduction of Apache Kafka (“Twitter for systems”)
• Asynchronous interactions through Apache Kafka – concepts, terminology
• Handson with Apache Kafka and Node
• Real world use cases and scenarios with Apache Kafka
• Handson Multi-microservice set up with Apache Kafka, Node and Dapr.io
Microservices in real life – with Node & Dapr.io
Classificatie: Public
Publiek
Programming against Kafka: Client Libraries
• Client libraries
• C/C++
• Python
• Go
• Java
• .NET
• JavaScript/Node
• Ruby
• Scala
• and more..
• Also: REST Proxy (part of open source Confluent Platform)
• Produce, Consumer and manage through REST API calls
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Programming against Kafka:
Typical Steps in a Client Producer Application
• Create a connection
• connected to one or more brokers in a cluster or to the Zookeeper node
• you need the broker-endpoints or the Zookeeper endpoint
• optionally use credentials or certificate for authentication
• Create a Producer on top of the connection
• When the Producer-Connection is available…
• [Optionally] Start a Transaction
• Produce message[s] to topic(s)
[or specific topic partition(s)]
• [Optionally] Commit the Transaction
• [Repeat Message Production]
• Disconnect the producer/close the connection
Microservices & Apache Kafka - 24 maart 2021
Client
Application
9094
9093
9092
2181
Classificatie: Public
Publiek
Programming against Kafka:
Typical Steps in a Client Consumer Application
• Create a connection
• connected to one or more brokers in a cluster or to Zookeeper node
• you need the broker-endpoints or the Zookeeper endpoint
• optionally use credentials or certificate for authentication
• Create a Consumer or a ConsumerStream on top of the connection
• Subscribing to one or more topics
• [Optionally] Associating with a Consumer Group
• (Which leads to a link to one or topic
more partitions on the Kafka brokers)
• [Optionally] Overriding the auto-commit
• When the Consumer or Stream is available…
• Consume message[s] (from the specified subscriptions)
• [Optionally, depending on auto-commit poperty]
Commit the Transaction
• [Repeat Message Consumption]
• Disconnect the consumer/close the connection
Microservices & Apache Kafka - 24 maart 2021
Client
Application
9094
9093
9092
2181
Classificatie: Public
Publiek
Node and Kafka
• We will use NPM module node-rdkafka to facilitate the interaction with
Apache Kafka from our Node application
• This module leverages a C/C++ library for Kafka interactions
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Node and Kafka – a simple producer
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Node and Kafka – a simple producer
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Node and Kafka – a simple producer
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Node and Kafka – a simple producer
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Node and Kafka – a simple producer
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Node and Kafka – a simple producer
Microservices & Apache Kafka - 24 maart 2021
Client
Application
9094
9093
9092
test-topic
1
2
Classificatie: Public
Publiek
Node and Kafka – a simple consumer
Microservices & Apache Kafka - 24 maart 2021
9094
9093
9092
test-topic
Classificatie: Public
Publiek
Node and Kafka – a simple consumer
Microservices & Apache Kafka - 24 maart 2021
Client
Application
9094
9093
9092
test-topic
1
2
Classificatie: Public
Publiek
Lab – Programmatic interaction with Apache Kafka
• Prequisite: local Node runtime
• Step Two:
• Node application to Produce Messages to Kafka Topic
• Node application to Consume Messages from Kafka Topic
• Bonus Step Three:
• Node Web Application to Produce Messages from HTTP Request
• Node Web Application to return Messages on Topic in HTTP Response
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Microservices & Apache Kafka - 24 maart 2021
Produce
Consume
kjynvuby-default
Classificatie: Public
Publiek
Utility company with data. Lots of it.
Microservices & Apache Kafka - 24 maart 2021
Interesting mix of operational, real time systems in physical environments, large scale enterprise systems for
1000s of internal professionals and millions of external consumers – with a mission to improve the world
Classificatie: Public
Publiek
Utility Company looking for Performance, Scalability and
Availability in their core data sets
Microservices & Apache Kafka - 24 maart 2021
CRM
Meter Readings
batch
Invoicing
Billing
Marketing
Campaigns
Load on Core Systems &
effect on Performance
Availability Core Systems
Classificatie: Public
Publiek
Utility Company looking for Performance, Scalability and
Availability in their core data sets
Microservices & Apache Kafka - 24 maart 2021
CRM
Meter Readings
Invoicing
Billing
Marketing
Campaigns
CRM
Cache DB
Meter
Readings
Cache DB
Classificatie: Public
Publiek
Utility Company looking for Performance, Scalability and
Availability in their core data sets
Microservices & Apache Kafka - 24 maart 2021
CRM
Meter Readings
Invoicing
Billing
Marketing
Campaigns
CRM
Cache DB
Meter
Readings
Cache DB
Classificatie: vertrouwelijk
Event Sourcing
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Event Sourcing
Microservices & Apache Kafka - 24 maart 2021
Events Event Store
Current State
accountId:
123
amount: 10
Owner: Jane Doe
Classificatie: Public
Publiek
Event Sourcing
Microservices & Apache Kafka - 24 maart 2021
Events Event Store
Current State
Other State Aggregate
Classificatie: Public
Publiek
Event Sourcing
• Event Store is immutable – append-only log of domain state transitions
• It is the truth about data – everything else is derived
• Replay events
• to (re)construct a representation of the current state (aggregate)
• up to a specific time to recreate moments in time
• in Test environment to investigate an issue
• on a remote location to create mirror & share state across boundaries
• produce a fine grained audit trail
• Challenges
• Time required to reconstruct state
• Grain of aggregates / definition of domain events
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Retail chain – 1200 stores and one central environment
Microservices in real life – with Node & Dapr.io
Central Environment
(on Azure)
Store A
Store B
Store C
Store D
Classificatie: Public
Publiek
Retail chain – 1200 stores and one central environment
Microservices in real life – with Node & Dapr.io
Central Environment
(on Azure)
Store A
Store B
Store C
Store D
• fast
• capable of high volume
• reliable / transactional
• cross technology
• not invasive
• future proof (and proven)
• bi-directional
Classificatie: Public
Publiek
Outbound – from central to 1200 stores
Microservices in real life – with Node & Dapr.io
Central Environment
(on Azure)
Store A
Store B
Store C
Store D
Classificatie: Public
Publiek
Outbound – from central to 1200 stores
Microservices in real life – with Node & Dapr.io
Central Environment
(on Azure)
Store A
Store B
Store C
Store D
Classificatie: Public
Publiek
Retail chain – 1200 stores and one central environment
Microservices in real life – with Node & Dapr.io
Central Environment
(on Azure)
Store A
Store B
Store C
Store D
Classificatie: Public
Publiek
Inbound – from 1200 stores to Central
Microservices in real life – with Node & Dapr.io
Central Environment
(on Azure)
Store A
Store B
Store C
Store D
Classificatie: Public
Publiek
Inbound – from 1200 stores to Central
Microservices in real life – with Node & Dapr.io
Central Environment
(on Azure)
Store A
Store B
Store C
Store D
Classificatie: Public
Publiek
Web Portal – Faster, Simpler and more Available
Microservices in real life – with Node & Dapr.io
Lab
Systems Web Portal
Classificatie: Public
Publiek
Web Portal – The Original Situation (2014)
Microservices in real life – with Node & Dapr.io
Relational Database
Service Bus
Lab
Systems Web Portal
SOAP/XML
SQL & Stored
Procedures
Classificatie: Public
Publiek
Web Portal – Faster, Simpler and more Available (2021)
Microservices in real life – with Node & Dapr.io
Relational Database
Service Bus
Lab
Systems
Web Portal
SOAP/XML
Kafka
Connect
Azure Cloud
NoSQL
Database
Kafka
REST/JSON
Changed
Data Capture
Classificatie: Public
Publiek
Apache Kafka is more than the core distributed platform
And there is more to distributed event platforms than Kafka
• Apache Kafka is surrounded by an ecosystem
• Primary supporting company: Confluent
• Extensions, Tools, Enterprise Edition
• Supporting resources (books, articles, tutorials, conferences)
• Partner companies
• Managed cloud services
• Kafka-compatible Public Cloud offerings
• Kafka-like offerings
• Competitors, imitators, …
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Ecosystem – Kafka and Friends
• Kafka Schema Registry – manage message schema definitions
• Kafka Connect – read data and change events
from many sources and/or write to many targets
• Also see Debezium
• Kafka Streams
• Kafka KSQL
• Confluent Enterprise
• Enterprise Grade Security
• Replicator
(synch across regions)
• Ops (Operations) support
• Confluent Managed Kafka Cloud Offering
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Confluent offerings
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Select Running Count
from <stream of tweet events>
select tag
, count(*) tweet_count
from tweets
Where tag = 'COVID2019' or tag = 'KAFKA'
group
by tag
Microservices & Apache Kafka - 24 maart 2021
<--- streaming data
Classificatie: Public
Publiek
Topic
Continuous Queries on Streaming Data
• Count Events, Aggregate Payloads, Filter, Combine & Enrich…
• … and produce: new events
Microservices & Apache Kafka - 24 maart 2021
Topic
Topic
Processor
Topic
Processor
Table
Classificatie: Public
Publiek
Alternatives for Apache Kafka’s
Distributed Streaming Event Platform
• Apache Pulsar
• Solace PubSub+ Event Portal
• Rabbit MQ
• Apache Active MQ
• Streaming Data libraries
• Apache Spark Streaming, Conduit, Faust, Apache Flink, Apache Storm,
Samza, Apache Beam, Apache Flume
Microservices & Apache Kafka - 24 maart 2021
Classificatie: Public
Publiek
Managed Kafka (-like) Cloud Offering
• Confluent
• AWS
• SQS
• Managed Streaming for Apache Kafka (Amazon MSK)
• EventBridge, Kinesis
• Azure
• Event Hub
• EventGrid, Stream Analytics
• Oracle Cloud Infrastructure
• Streams
• Google Cloud Platform
• PubSub
• DataFlow
• … (Heroku Managed Kafka, Alibaba Cloud LogHub, IBM Event Streams,…)
Microservices & Apache Kafka - 24 maart 2021
?
Classificatie: Public
Publiek
Slide from last week:
Pub/Sub with Dapr from Node applications
Microservices in real life – with Node & Dapr.io
sidecar (the personal assistant)
Node SDK
for Dapr
Pub/Sub
components
publish message
components.yaml
PubSub
Brokers
pub/sub
interface
Node SDK
for Dapr
components.yaml
subscribe on topic
with handler function
message sent to handler
Classificatie: Public
Publiek
Pub/Sub with Dapr from Node applications
Microservices in real life – with Node & Dapr.io
sidecar (the personal assistant)
Node SDK
for Dapr
Pub/Sub
components
publish message
components.yaml
PubSub
Brokers
Node SDK
for Dapr
components.yaml
subscribe on topic
with handler function
message sent to handler
pub/sub
interface
publish
message
Classificatie: Public
Publiek
Pub/Sub with Dapr from Node applications
Microservices in real life – with Node & Dapr.io
sidecar (the personal assistant)
Node SDK
for Dapr
Pub/Sub
components
publish message
ponents.yaml
PubSub
Brokers
Node SDK
for Dapr
components.yaml
pub/sub
interface
subscribe
on topic
message sent
to handler
Classificatie: Public
Publiek
Pub/Sub with Dapr from Node applications
Replace Redis by Apache Kafka
Microservices in real life – with Node & Dapr.io
sidecar (the personal assistant)
Node SDK
for Dapr
Pub/Sub
components
publish message
to topic
components.yaml
PubSub
Brokers
pub/sub
interface
Node SDK
for Dapr
components.yaml
subscribe on topic
with handler function
message sent to handler
9094
9093
9092
test-topic
Classificatie: Public
Publiek
Labs on Kafka and Node and Dapr
• Programmatically work with Kafka from Node – with and without Dapr
• publishing and consuming messages
• Implement the CQRS pattern between two microservices
• one is master of data, the other has a stand alone replica – to be synchronized
• Implement decoupled conversation between multiple
microservices – through Kafka
Microservices in real life – with Node & Dapr.io
Billing Engine
CRM
Handles assignment on
workflow queue to produce a
bill for a customer
Publish Event to Kafka Topic
with question details and
conversation identifier
Consume Event, handle the question and publish
a response with customer details on a second
queue – including the conversation identifier
questions
answers
workflow-
queue
Billing Run
Coordinator
Create bill
processing
instructions for
customers
1
2
3
4
5
bill
Classificatie: Public
Publiek
Lab – Microservice interaction
• Asynchronous conversation between microservices
Microservices & Apache Kafka - 24 maart 2021
Billing Engine
CRM
Handles assignment on
workflow queue to produce
a bill for a customer
Publish Event to Kafka
Topic with question details
and conversation identifier
Consume Event, handle the question
and publish a response with customer
details on a second queue – including
the conversation identifier
questions
answers
workflow-queue
Billing Run
Coordinator
Create bill
processing
instructions for
customers
1
2
3
4
5
bill
Classificatie: Public
Publiek
Summary
• => == =>
• Apache Kafka is emerging as platform of choice for message exchange in a world of
• Microservices
• Event Sourcing, CQRS and Data Source Synchronization
• Clouds
• Fast Data (IoT) and Streaming Analysis
• Real time data integration & distribution
• Getting started with Apache Kafka is not very hard at all
• The platform is open source – and has broad client support (Java, Node, …)
• Many resources are available – tutorials, blog article, demonstrations, presentation
slides and recordings of conference sessions, samples on GitHub
• Using Docker Compose it is quite easy to quickly run a Kafka Cluster
(and with CloudKarafka even easier)
• Note: managing a production grade cluster is not so easy
Microservices & Apache Kafka - 24 maart 2021
Classificatie: vertrouwelijk
Microservices in real life – with Node & Dapr.io
you are invited to come do an internship and explore job opportunities with us!
lucas.jellema@amis.nl | technology.amis.nl | @lucasjellema | lucas-jellema

More Related Content

PDF
Introduction to Kafka Streams
PPSX
Event Sourcing & CQRS, Kafka, Rabbit MQ
PDF
[115]쿠팡 서비스 클라우드 마이그레이션 통해 배운것들
PPTX
Introduction to microservices
PPTX
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
PDF
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
ODP
Stream processing using Kafka
PPTX
Azure Compute, Networking and Storage Overview
Introduction to Kafka Streams
Event Sourcing & CQRS, Kafka, Rabbit MQ
[115]쿠팡 서비스 클라우드 마이그레이션 통해 배운것들
Introduction to microservices
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
An Architectural Deep Dive With Kubernetes And Containers Powerpoint Presenta...
Stream processing using Kafka
Azure Compute, Networking and Storage Overview

What's hot (20)

PPTX
MSA ( Microservices Architecture ) 발표 자료 다운로드
PPTX
Deep Dive into Apache Kafka
PPTX
Dynamic Rule-based Real-time Market Data Alerts
PDF
Kafka 101 and Developer Best Practices
PDF
Hello, kafka! (an introduction to apache kafka)
PDF
Microservice architecture
PPTX
Domain events & Kafka in Ruby applications
PDF
ECS to EKS 마이그레이션 경험기 - 유용환(Superb AI) :: AWS Community Day Online 2021
PDF
Kubernetes 101
PDF
The Beginner’s Guide To Spring Cloud
PPSX
CI-CD Jenkins, GitHub Actions, Tekton
PDF
Apache Kafka Fundamentals for Architects, Admins and Developers
PPTX
Kafka 101
PDF
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
PPTX
Microservices Part 3 Service Mesh and Kafka
PDF
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
PDF
Kubernetes networking & Security
ODP
Introduction to Kafka connect
PDF
When NOT to use Apache Kafka?
PDF
Kafka Streams State Stores Being Persistent
MSA ( Microservices Architecture ) 발표 자료 다운로드
Deep Dive into Apache Kafka
Dynamic Rule-based Real-time Market Data Alerts
Kafka 101 and Developer Best Practices
Hello, kafka! (an introduction to apache kafka)
Microservice architecture
Domain events & Kafka in Ruby applications
ECS to EKS 마이그레이션 경험기 - 유용환(Superb AI) :: AWS Community Day Online 2021
Kubernetes 101
The Beginner’s Guide To Spring Cloud
CI-CD Jenkins, GitHub Actions, Tekton
Apache Kafka Fundamentals for Architects, Admins and Developers
Kafka 101
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Microservices Part 3 Service Mesh and Kafka
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Kubernetes networking & Security
Introduction to Kafka connect
When NOT to use Apache Kafka?
Kafka Streams State Stores Being Persistent
Ad

Similar to Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschool, Spring 2022) (20)

PPTX
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
PPTX
Mobilize Your Community Army: A Commercial OpenSource's Perspective
PPTX
Introducing Apache Kafka and why it is important to Oracle, Java and IT profe...
PDF
How to contribute to Serverless Apache OpenWhisk OpenSource101 NCSU
PPT
Snrg2011 6.15.2.sta canney_suranofsky
PPTX
Use of "NewGenLib" Open Source Software for Library Automation, Digital Libra...
PPT
Emerging Trends in Librarianship (2008)
PPTX
RA21 Charleston Library Conference Presentation
PPTX
Microservices, Node, Dapr and more - Part One (Fontys Hogeschool, Spring 2022)
PDF
Knowledge Plaza
PDF
Knowledge Plaza
PPT
Emerging Technologies
PDF
Message Architectures in Distributed Systems - Data Day Texas 2013-01-11
PPTX
2016 05 sanger
PPTX
Next generation repositories
PPTX
The Europeana Strategy and Linked Open Data
PDF
ADV Slides: Trends in Streaming Analytics and Message-oriented Middleware
PDF
Drupal In 1 Hour
PPTX
CouchbasetoHadoop_Matt_Michael_Justin v4
PPTX
Yow Conference Dec 2013 Netflix Workshop Slides with Notes
What is Kafka & why is it Important? (UKOUG Tech17, Birmingham, UK - December...
Mobilize Your Community Army: A Commercial OpenSource's Perspective
Introducing Apache Kafka and why it is important to Oracle, Java and IT profe...
How to contribute to Serverless Apache OpenWhisk OpenSource101 NCSU
Snrg2011 6.15.2.sta canney_suranofsky
Use of "NewGenLib" Open Source Software for Library Automation, Digital Libra...
Emerging Trends in Librarianship (2008)
RA21 Charleston Library Conference Presentation
Microservices, Node, Dapr and more - Part One (Fontys Hogeschool, Spring 2022)
Knowledge Plaza
Knowledge Plaza
Emerging Technologies
Message Architectures in Distributed Systems - Data Day Texas 2013-01-11
2016 05 sanger
Next generation repositories
The Europeana Strategy and Linked Open Data
ADV Slides: Trends in Streaming Analytics and Message-oriented Middleware
Drupal In 1 Hour
CouchbasetoHadoop_Matt_Michael_Justin v4
Yow Conference Dec 2013 Netflix Workshop Slides with Notes
Ad

More from Lucas Jellema (20)

PPTX
Introduction to web application development with Vue (for absolute beginners)...
PPTX
Making the Shift Left - Bringing Ops to Dev before bringing applications to p...
PPTX
Lightweight coding in powerful Cloud Development Environments (DigitalXchange...
PPTX
Apache Superset - open source data exploration and visualization (Conclusion ...
PPTX
CONNECTING THE REAL WORLD TO ENTERPRISE IT – HOW IoT DRIVES OUR ENERGY TRANSI...
PPTX
Help me move away from Oracle - or not?! (Oracle Community Tour EMEA - LVOUG...
PPTX
Op je vingers tellen... tot 1000!
PPTX
IoT - from prototype to enterprise platform (DigitalXchange 2022)
PPTX
Who Wants to Become an IT Architect-A Look at the Bigger Picture - DigitalXch...
PPTX
Steampipe - use SQL to retrieve data from cloud, platforms and files (Code Ca...
PPTX
Automation of Software Engineering with OCI DevOps Build and Deployment Pipel...
PPTX
Introducing Dapr.io - the open source personal assistant to microservices and...
PPTX
How and Why you can and should Participate in Open Source Projects (AMIS, Sof...
PPTX
6Reinventing Oracle Systems in a Cloudy World (RMOUG Trainingdays, February 2...
PPTX
Help me move away from Oracle! (RMOUG Training Days 2022, February 2022)
PPTX
Tech Talks 101 - DevOps (jan 2022)
PPTX
Conclusion Code Cafe - Microcks for Mocking and Testing Async APIs (January 2...
PPTX
Cloud Native Application Development - build fast, low TCO, scalable & agile ...
PPTX
Software Engineering as the Next Level Up from Programming (Oracle Groundbrea...
PPTX
Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...
Introduction to web application development with Vue (for absolute beginners)...
Making the Shift Left - Bringing Ops to Dev before bringing applications to p...
Lightweight coding in powerful Cloud Development Environments (DigitalXchange...
Apache Superset - open source data exploration and visualization (Conclusion ...
CONNECTING THE REAL WORLD TO ENTERPRISE IT – HOW IoT DRIVES OUR ENERGY TRANSI...
Help me move away from Oracle - or not?! (Oracle Community Tour EMEA - LVOUG...
Op je vingers tellen... tot 1000!
IoT - from prototype to enterprise platform (DigitalXchange 2022)
Who Wants to Become an IT Architect-A Look at the Bigger Picture - DigitalXch...
Steampipe - use SQL to retrieve data from cloud, platforms and files (Code Ca...
Automation of Software Engineering with OCI DevOps Build and Deployment Pipel...
Introducing Dapr.io - the open source personal assistant to microservices and...
How and Why you can and should Participate in Open Source Projects (AMIS, Sof...
6Reinventing Oracle Systems in a Cloudy World (RMOUG Trainingdays, February 2...
Help me move away from Oracle! (RMOUG Training Days 2022, February 2022)
Tech Talks 101 - DevOps (jan 2022)
Conclusion Code Cafe - Microcks for Mocking and Testing Async APIs (January 2...
Cloud Native Application Development - build fast, low TCO, scalable & agile ...
Software Engineering as the Next Level Up from Programming (Oracle Groundbrea...
Triple C - Centralize, Cloudify and Consolidate Dozens of Oracle Databases (O...

Recently uploaded (20)

PDF
Digital Strategies for Manufacturing Companies
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPT
Introduction Database Management System for Course Database
PPTX
assetexplorer- product-overview - presentation
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
top salesforce developer skills in 2025.pdf
PDF
Nekopoi APK 2025 free lastest update
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Transform Your Business with a Software ERP System
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Digital Strategies for Manufacturing Companies
2025 Textile ERP Trends: SAP, Odoo & Oracle
Computer Software and OS of computer science of grade 11.pptx
Introduction Database Management System for Course Database
assetexplorer- product-overview - presentation
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
top salesforce developer skills in 2025.pdf
Nekopoi APK 2025 free lastest update
Operating system designcfffgfgggggggvggggggggg
Reimagine Home Health with the Power of Agentic AI​
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How to Choose the Right IT Partner for Your Business in Malaysia
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms I-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Transform Your Business with a Software ERP System
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf

Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschool, Spring 2022)

  • 1. Classificatie: vertrouwelijk Microservices in real life – with Apache Kafka, Node & Dapr.io Part 2 March 2022 Lucas Jellema Architect & CTO AMIS | Conclusion
  • 2. Classificatie: vertrouwelijk Microservices in real life – with Node & Dapr.io Founded in 1991 by students from University of Twente – Aircraft Maintenance Information System (AMIS) 80 colleagues, located in Nieuwegein the core of what we do: working with Data. partnering with peers and companies in several countries Lucas Jellema (2002) Cloud Solution Architect & CTO [email protected] | technology.amis.nl | @lucasjellema | lucas-jellema
  • 3. Classificatie: vertrouwelijk Microservices in real life – with Node & Dapr.io Data Engineering, Data Analytics (& Data Science) Data & Application Integration web applications Internet of Things cloud, DevOps, PaaS, streaming, microservices, Software Studio, database, software engineering Oracle, Microsoft Azure, open source, Java, SQL, NodeJS, Python,Kafka React/Angular
  • 4. Classificatie: vertrouwelijk Microservices in real life – with Node & Dapr.io
  • 5. Classificatie: Public Publiek Overview • Part One (last week) • Microservices recap • Dapr.io – personal assistant for applications & distributed application runtime • Handson with Dapr.io • Quick Intro to programming in Node[.js] • Handson Microservice implementation with Node and Dapr.io • Part Two (today) • Introduction of Apache Kafka (“Twitter for systems”) • Asynchronous interactions through Apache Kafka – concepts, terminology • Handson with Apache Kafka and Node • Real world use cases and scenarios with Apache Kafka • Handson Multi-microservice set up with Apache Kafka, Node and Dapr.io Microservices in real life – with Node & Dapr.io
  • 6. Classificatie: Public Publiek Assumed is • A development environment with VS Code, Docker and Docker Composer, the ability (permissions) to install software • Knowledge of • HTTP, REST, JSON • Containers, Docker (and Kubernetes) • Java or C# • SQL and a database (MySQL or PostgreSQL or SQL Server) • perhaps Message Broker/Event Queue (RabbitMQ?), Cache (Redis?) • Cloud fundamentals • Microservices concepts Microservices in real life – with Node & Dapr.io
  • 7. Classificatie: Public Publiek It would be so nice if I could publish my ideas and actions, accessible near instantly for everyone who is interested Heck, I do not even know these people and they may not know me [personally] – just my pearls of wisdom. And if they are late to the party, they can also check out the historic archives of my eloquence Without fretting about the numbers of readers involved and whether they are in the same time zone as me and online when I publish my messages – and which device they use
  • 8. Classificatie: Public Publiek It would be so nice if I could publish my ideas and actions, accessible near instantly for everyone who is interested Heck, I do not even know these people and they may not know me [personally] – just my pearls of wisdom. And if they are late to the party, they can also check out the historic archives of my eloquence Without fretting about the numbers of readers involved and whether they are in the same time zone as me and online when I publish my messages – and which device they use
  • 9. Classificatie: Public Publiek It would be so nice if I could publish my ideas and actions, accessible near instantly for everyone who is interested Heck, I do not even know these people and they may not know me [personally] – just my pearls of wisdom. And if they are late to the party, they can also check out the historic archives of my eloquence Without fretting about the numbers of readers involved and whether they are in the same time zone as me and online when I publish my messages – and which device they use
  • 10. Classificatie: Public Publiek • Decoupled communication • 0, 1 or many followers • Scalable number of messages (and parties) • Reliable (mostly available, few messages lost) • Full history • Open: cross device, cross location • Not Sub-second, near real-time fast • Rate limited (#messages/minute) • Size limited (140-280 characters) • Format limited (text) • Not for private interactions • Not (really) for programmatic use
  • 11. Classificatie: Public Publiek What does the Twitter for System Driven Event Interaction look like? Microservices & Apache Kafka - 24 maart 2021 • Decoupled communication – organized per topic • 0, 1 or many Consumers per Topic • Scalable number of messages (and parties) • Reliable (distributed) • Full history • Open: libraries in many technologies & REST APIs
  • 12. Classificatie: Public Publiek What does the Twitter for System Driven Event Interaction look like? Microservices & Apache Kafka - 24 maart 2021 • Decoupled communication – organized per topic • 0, 1 or many Consumers per Topic • Scalable number of messages (and parties) • Reliable (distributed) • Full history • Open: libraries in many technologies & REST APIs • Near real-time fast • No Rate Limit • No enforced size limit • Anything goes (it’s all byte[]) • On premises or in cloud, private or trusted • Very much for programmatic use
  • 13. Classificatie: Public Publiek Events Producers Consumers Robust, QoS, Scalable, Fast, History Retention Order preserved Containerized/Cloud- enabled Open Microservices & Apache Kafka - 24 maart 2021
  • 14. Classificatie: Public Publiek Messaging as we know it • JMS, IBM MQ, MS MQ, RabbitMQ, MQTT, XMPP, WebSockets, Apache ActiveMQ, … • Challenges • Costs • Scalability (size and speed) • (lack of) Distribution (and therefore availability) • Complexity of infrastructure • Message delivery guarantees (reliability) • Lack of technology openness • Deal with temporarily offline consumers • Retain history Microservices & Apache Kafka - 24 maart 2021
  • 15. Classificatie: Public Publiek Introducing Apache Kafka • ..- 2010 – creation at Linkedin • Message Bus | Event Broker • High volume, low latency, highly reliable, cross technology • Scalable, distributed, strict message ordering, …. • 2011/2012 – open source under the Apache Incubator/ Top Project • Kafka is used by many large corporations: • Walmart, Cisco, Netflix, PayPal, LinkedIn, eBay, Spotify, Uber, Sift Science, Zalando, The New York Times, Airbnb, Coursera, ING Bank,… • … and embraced by many software vendors & cloud providers • Commercial backing by and Enterprise support from Confluent Microservices & Apache Kafka - 24 maart 2021
  • 16. Classificatie: Public Publiek Producers Consumers tcp tcp Microservices & Apache Kafka - 24 maart 2021 Client polls Event Broker for messages
  • 18. Classificatie: Public Publiek Kafka terminology • Topic • Message • == ByteArray • Broker • Producer • Consumer • Offset Producer Consumer Topic Broker Key Value Time Message Microservices & Apache Kafka - 24 maart 2021 offset (for a specific consumer)
  • 20. Classificatie: Public Publiek Consuming • Messages are available to consumers only when they have been committed by the producer • Kafka does not push • Unlike JMS • Read does not destroy • Unlike JMS Topic • (some | much | all) History available • Offline consumers can catch up • Consumers can re-consume from the past (just move offset) • Delivery Guarantees • Ordering maintained • At-least-once (per consumer) by default; at-most-once and exactly-once can be implemented Microservices & Apache Kafka - 24 maart 2021
  • 21. Classificatie: Public Publiek The company bulletin board Microservices & Apache Kafka - 24 maart 2021 ! !! “@#” ! ! !!
  • 22. Classificatie: Public Publiek The company bulletin board Microservices & Apache Kafka - 24 maart 2021 ! ! !! “@#$” € $ ¥ ₤ ₨
  • 26. Classificatie: Public Publiek Consumers Topic Broker Consumer Group tition Microservices & Apache Kafka - 24 maart 2021 Cluster Consumer Group • each consumer group consumes all messages (once) • each consumer in a group consumes from one or more partitions (no partition is consumed by more than one consumer in a group) • when more consumers in a group than partitions in the topic, some consumers get no messages • when consumers disappear from a group, their partition(s) are reassigned to other consumers in the group
  • 27. Classificatie: Public Publiek What’s so special? • Durable transactions • Scalable • High volume • High speed • Parallel processing • Available • Distributed • Open • Quick start • Free (no license costs) • “Self Fulfilling Prophecy” leading to “de facto standard” (positive feedback loop feeding from buzz around Kafka) • Eco system, tools/libraries/resources, cloud services Microservices & Apache Kafka - 24 maart 2021
  • 28. Classificatie: Public Publiek Some Kafka Use Cases • Connected Cars, Manufacturing, Mobility, Gaming, Betting • Tesla: Processing and analyzing the data from their vehicles, smart grids, and factories and integrating with the rest of the IT backend services in real- time is a crucial piece of Tesla’s success Microservices in real life – with Node & Dapr.io https://kai-waehner.medium.com/when-not-to-use-apache-kafka-a35345226a9f
  • 29. Classificatie: Public Publiek Some Kafka Use Cases • Connected Cars, Manufacturing, Mobility, Gaming, Betting • Regulatory compliance and zero data loss are crucial. • transactionally safe data replication Microservices in real life – with Node & Dapr.io https://kai-waehner.medium.com/when-not-to-use-apache-kafka-a35345226a9f
  • 30. Classificatie: Public Publiek Some Kafka Use Cases • Connected Cars, Manufacturing, Mobility, Gaming, Betting • Royal Caribbean: Each cruise ship has a Kafka cluster running locally for use cases such as payment processing, loyalty information, customer recommendations, etc. Sync with shore when entering a port. Microservices in real life – with Node & Dapr.io https://kai-waehner.medium.com/when-not-to-use-apache-kafka-a35345226a9f
  • 31. Classificatie: Public Publiek Quick Demo – Apache Kafka through Kafka Console • Show interaction at the most basic level • Broker • Topic • partition • Produce Message • Consume Message • Consumer Group Microservices & Apache Kafka - 24 maart 2021 Docker Compose Browser Laptop 28042 9092 localhost kafka
  • 32. Classificatie: Public Publiek Lab: First steps with Apache Kafka • Using Kafka Console • Create a topic • Publish messages to topic • Using Kafka Console • Consume messages from topic • Work with Apache Kafka HQ GUI to • inspect the Kafka Cluster • produce additional messages • consume message from a special Consumer Group Microservices & Apache Kafka - 24 maart 2021 Docker Compose Browser Laptop 28042 9092 localhost kafka Lab Resources: https://github.com/lucasjellema/fontys-2022-microservices-kafka-dapr
  • 33. Classificatie: Public Publiek Lab Environment Microservices & Apache Kafka - 24 maart 2021 Docker Compose Browser Laptop 28042 9094 9093 9092 2181 28044 localhost kafka Lab Resources: https://github.com/lucasjellema/fontys-2022-microservices-kafka-dapr
  • 34. Classificatie: Public Publiek Partly Clouded Lab Environment Microservices & Apache Kafka - 24 maart 2021 Browser Laptop 2181 localhost CloudKarafka Console Lab Resources: - www.cloudkarafka.com/plans.html
  • 35. Classificatie: Public Publiek Agenda - • Part One (last week – microservices, Node, Dapr.io) • Part Two (today) • Introduction of Apache Kafka (“Twitter for systems”) • Asynchronous interactions through Apache Kafka – concepts, terminology • Handson with Apache Kafka and Node • Real world use cases and scenarios with Apache Kafka • Handson Multi-microservice set up with Apache Kafka, Node and Dapr.io Microservices in real life – with Node & Dapr.io
  • 36. Classificatie: Public Publiek Programming against Kafka: Client Libraries • Client libraries • C/C++ • Python • Go • Java • .NET • JavaScript/Node • Ruby • Scala • and more.. • Also: REST Proxy (part of open source Confluent Platform) • Produce, Consumer and manage through REST API calls Microservices & Apache Kafka - 24 maart 2021
  • 37. Classificatie: Public Publiek Programming against Kafka: Typical Steps in a Client Producer Application • Create a connection • connected to one or more brokers in a cluster or to the Zookeeper node • you need the broker-endpoints or the Zookeeper endpoint • optionally use credentials or certificate for authentication • Create a Producer on top of the connection • When the Producer-Connection is available… • [Optionally] Start a Transaction • Produce message[s] to topic(s) [or specific topic partition(s)] • [Optionally] Commit the Transaction • [Repeat Message Production] • Disconnect the producer/close the connection Microservices & Apache Kafka - 24 maart 2021 Client Application 9094 9093 9092 2181
  • 38. Classificatie: Public Publiek Programming against Kafka: Typical Steps in a Client Consumer Application • Create a connection • connected to one or more brokers in a cluster or to Zookeeper node • you need the broker-endpoints or the Zookeeper endpoint • optionally use credentials or certificate for authentication • Create a Consumer or a ConsumerStream on top of the connection • Subscribing to one or more topics • [Optionally] Associating with a Consumer Group • (Which leads to a link to one or topic more partitions on the Kafka brokers) • [Optionally] Overriding the auto-commit • When the Consumer or Stream is available… • Consume message[s] (from the specified subscriptions) • [Optionally, depending on auto-commit poperty] Commit the Transaction • [Repeat Message Consumption] • Disconnect the consumer/close the connection Microservices & Apache Kafka - 24 maart 2021 Client Application 9094 9093 9092 2181
  • 39. Classificatie: Public Publiek Node and Kafka • We will use NPM module node-rdkafka to facilitate the interaction with Apache Kafka from our Node application • This module leverages a C/C++ library for Kafka interactions Microservices & Apache Kafka - 24 maart 2021
  • 40. Classificatie: Public Publiek Node and Kafka – a simple producer Microservices & Apache Kafka - 24 maart 2021
  • 41. Classificatie: Public Publiek Node and Kafka – a simple producer Microservices & Apache Kafka - 24 maart 2021
  • 42. Classificatie: Public Publiek Node and Kafka – a simple producer Microservices & Apache Kafka - 24 maart 2021
  • 43. Classificatie: Public Publiek Node and Kafka – a simple producer Microservices & Apache Kafka - 24 maart 2021
  • 44. Classificatie: Public Publiek Node and Kafka – a simple producer Microservices & Apache Kafka - 24 maart 2021
  • 45. Classificatie: Public Publiek Node and Kafka – a simple producer Microservices & Apache Kafka - 24 maart 2021 Client Application 9094 9093 9092 test-topic 1 2
  • 46. Classificatie: Public Publiek Node and Kafka – a simple consumer Microservices & Apache Kafka - 24 maart 2021 9094 9093 9092 test-topic
  • 47. Classificatie: Public Publiek Node and Kafka – a simple consumer Microservices & Apache Kafka - 24 maart 2021 Client Application 9094 9093 9092 test-topic 1 2
  • 48. Classificatie: Public Publiek Lab – Programmatic interaction with Apache Kafka • Prequisite: local Node runtime • Step Two: • Node application to Produce Messages to Kafka Topic • Node application to Consume Messages from Kafka Topic • Bonus Step Three: • Node Web Application to Produce Messages from HTTP Request • Node Web Application to return Messages on Topic in HTTP Response Microservices & Apache Kafka - 24 maart 2021
  • 49. Classificatie: Public Publiek Microservices & Apache Kafka - 24 maart 2021 Produce Consume kjynvuby-default
  • 50. Classificatie: Public Publiek Utility company with data. Lots of it. Microservices & Apache Kafka - 24 maart 2021 Interesting mix of operational, real time systems in physical environments, large scale enterprise systems for 1000s of internal professionals and millions of external consumers – with a mission to improve the world
  • 51. Classificatie: Public Publiek Utility Company looking for Performance, Scalability and Availability in their core data sets Microservices & Apache Kafka - 24 maart 2021 CRM Meter Readings batch Invoicing Billing Marketing Campaigns Load on Core Systems & effect on Performance Availability Core Systems
  • 52. Classificatie: Public Publiek Utility Company looking for Performance, Scalability and Availability in their core data sets Microservices & Apache Kafka - 24 maart 2021 CRM Meter Readings Invoicing Billing Marketing Campaigns CRM Cache DB Meter Readings Cache DB
  • 53. Classificatie: Public Publiek Utility Company looking for Performance, Scalability and Availability in their core data sets Microservices & Apache Kafka - 24 maart 2021 CRM Meter Readings Invoicing Billing Marketing Campaigns CRM Cache DB Meter Readings Cache DB
  • 55. Classificatie: Public Publiek Event Sourcing Microservices & Apache Kafka - 24 maart 2021 Events Event Store Current State accountId: 123 amount: 10 Owner: Jane Doe
  • 56. Classificatie: Public Publiek Event Sourcing Microservices & Apache Kafka - 24 maart 2021 Events Event Store Current State Other State Aggregate
  • 57. Classificatie: Public Publiek Event Sourcing • Event Store is immutable – append-only log of domain state transitions • It is the truth about data – everything else is derived • Replay events • to (re)construct a representation of the current state (aggregate) • up to a specific time to recreate moments in time • in Test environment to investigate an issue • on a remote location to create mirror & share state across boundaries • produce a fine grained audit trail • Challenges • Time required to reconstruct state • Grain of aggregates / definition of domain events Microservices & Apache Kafka - 24 maart 2021
  • 58. Classificatie: Public Publiek Retail chain – 1200 stores and one central environment Microservices in real life – with Node & Dapr.io Central Environment (on Azure) Store A Store B Store C Store D
  • 59. Classificatie: Public Publiek Retail chain – 1200 stores and one central environment Microservices in real life – with Node & Dapr.io Central Environment (on Azure) Store A Store B Store C Store D • fast • capable of high volume • reliable / transactional • cross technology • not invasive • future proof (and proven) • bi-directional
  • 60. Classificatie: Public Publiek Outbound – from central to 1200 stores Microservices in real life – with Node & Dapr.io Central Environment (on Azure) Store A Store B Store C Store D
  • 61. Classificatie: Public Publiek Outbound – from central to 1200 stores Microservices in real life – with Node & Dapr.io Central Environment (on Azure) Store A Store B Store C Store D
  • 62. Classificatie: Public Publiek Retail chain – 1200 stores and one central environment Microservices in real life – with Node & Dapr.io Central Environment (on Azure) Store A Store B Store C Store D
  • 63. Classificatie: Public Publiek Inbound – from 1200 stores to Central Microservices in real life – with Node & Dapr.io Central Environment (on Azure) Store A Store B Store C Store D
  • 64. Classificatie: Public Publiek Inbound – from 1200 stores to Central Microservices in real life – with Node & Dapr.io Central Environment (on Azure) Store A Store B Store C Store D
  • 65. Classificatie: Public Publiek Web Portal – Faster, Simpler and more Available Microservices in real life – with Node & Dapr.io Lab Systems Web Portal
  • 66. Classificatie: Public Publiek Web Portal – The Original Situation (2014) Microservices in real life – with Node & Dapr.io Relational Database Service Bus Lab Systems Web Portal SOAP/XML SQL & Stored Procedures
  • 67. Classificatie: Public Publiek Web Portal – Faster, Simpler and more Available (2021) Microservices in real life – with Node & Dapr.io Relational Database Service Bus Lab Systems Web Portal SOAP/XML Kafka Connect Azure Cloud NoSQL Database Kafka REST/JSON Changed Data Capture
  • 68. Classificatie: Public Publiek Apache Kafka is more than the core distributed platform And there is more to distributed event platforms than Kafka • Apache Kafka is surrounded by an ecosystem • Primary supporting company: Confluent • Extensions, Tools, Enterprise Edition • Supporting resources (books, articles, tutorials, conferences) • Partner companies • Managed cloud services • Kafka-compatible Public Cloud offerings • Kafka-like offerings • Competitors, imitators, … Microservices & Apache Kafka - 24 maart 2021
  • 69. Classificatie: Public Publiek Ecosystem – Kafka and Friends • Kafka Schema Registry – manage message schema definitions • Kafka Connect – read data and change events from many sources and/or write to many targets • Also see Debezium • Kafka Streams • Kafka KSQL • Confluent Enterprise • Enterprise Grade Security • Replicator (synch across regions) • Ops (Operations) support • Confluent Managed Kafka Cloud Offering Microservices & Apache Kafka - 24 maart 2021
  • 71. Classificatie: Public Publiek Select Running Count from <stream of tweet events> select tag , count(*) tweet_count from tweets Where tag = 'COVID2019' or tag = 'KAFKA' group by tag Microservices & Apache Kafka - 24 maart 2021 <--- streaming data
  • 72. Classificatie: Public Publiek Topic Continuous Queries on Streaming Data • Count Events, Aggregate Payloads, Filter, Combine & Enrich… • … and produce: new events Microservices & Apache Kafka - 24 maart 2021 Topic Topic Processor Topic Processor Table
  • 73. Classificatie: Public Publiek Alternatives for Apache Kafka’s Distributed Streaming Event Platform • Apache Pulsar • Solace PubSub+ Event Portal • Rabbit MQ • Apache Active MQ • Streaming Data libraries • Apache Spark Streaming, Conduit, Faust, Apache Flink, Apache Storm, Samza, Apache Beam, Apache Flume Microservices & Apache Kafka - 24 maart 2021
  • 74. Classificatie: Public Publiek Managed Kafka (-like) Cloud Offering • Confluent • AWS • SQS • Managed Streaming for Apache Kafka (Amazon MSK) • EventBridge, Kinesis • Azure • Event Hub • EventGrid, Stream Analytics • Oracle Cloud Infrastructure • Streams • Google Cloud Platform • PubSub • DataFlow • … (Heroku Managed Kafka, Alibaba Cloud LogHub, IBM Event Streams,…) Microservices & Apache Kafka - 24 maart 2021 ?
  • 75. Classificatie: Public Publiek Slide from last week: Pub/Sub with Dapr from Node applications Microservices in real life – with Node & Dapr.io sidecar (the personal assistant) Node SDK for Dapr Pub/Sub components publish message components.yaml PubSub Brokers pub/sub interface Node SDK for Dapr components.yaml subscribe on topic with handler function message sent to handler
  • 76. Classificatie: Public Publiek Pub/Sub with Dapr from Node applications Microservices in real life – with Node & Dapr.io sidecar (the personal assistant) Node SDK for Dapr Pub/Sub components publish message components.yaml PubSub Brokers Node SDK for Dapr components.yaml subscribe on topic with handler function message sent to handler pub/sub interface publish message
  • 77. Classificatie: Public Publiek Pub/Sub with Dapr from Node applications Microservices in real life – with Node & Dapr.io sidecar (the personal assistant) Node SDK for Dapr Pub/Sub components publish message ponents.yaml PubSub Brokers Node SDK for Dapr components.yaml pub/sub interface subscribe on topic message sent to handler
  • 78. Classificatie: Public Publiek Pub/Sub with Dapr from Node applications Replace Redis by Apache Kafka Microservices in real life – with Node & Dapr.io sidecar (the personal assistant) Node SDK for Dapr Pub/Sub components publish message to topic components.yaml PubSub Brokers pub/sub interface Node SDK for Dapr components.yaml subscribe on topic with handler function message sent to handler 9094 9093 9092 test-topic
  • 79. Classificatie: Public Publiek Labs on Kafka and Node and Dapr • Programmatically work with Kafka from Node – with and without Dapr • publishing and consuming messages • Implement the CQRS pattern between two microservices • one is master of data, the other has a stand alone replica – to be synchronized • Implement decoupled conversation between multiple microservices – through Kafka Microservices in real life – with Node & Dapr.io Billing Engine CRM Handles assignment on workflow queue to produce a bill for a customer Publish Event to Kafka Topic with question details and conversation identifier Consume Event, handle the question and publish a response with customer details on a second queue – including the conversation identifier questions answers workflow- queue Billing Run Coordinator Create bill processing instructions for customers 1 2 3 4 5 bill
  • 80. Classificatie: Public Publiek Lab – Microservice interaction • Asynchronous conversation between microservices Microservices & Apache Kafka - 24 maart 2021 Billing Engine CRM Handles assignment on workflow queue to produce a bill for a customer Publish Event to Kafka Topic with question details and conversation identifier Consume Event, handle the question and publish a response with customer details on a second queue – including the conversation identifier questions answers workflow-queue Billing Run Coordinator Create bill processing instructions for customers 1 2 3 4 5 bill
  • 81. Classificatie: Public Publiek Summary • => == => • Apache Kafka is emerging as platform of choice for message exchange in a world of • Microservices • Event Sourcing, CQRS and Data Source Synchronization • Clouds • Fast Data (IoT) and Streaming Analysis • Real time data integration & distribution • Getting started with Apache Kafka is not very hard at all • The platform is open source – and has broad client support (Java, Node, …) • Many resources are available – tutorials, blog article, demonstrations, presentation slides and recordings of conference sessions, samples on GitHub • Using Docker Compose it is quite easy to quickly run a Kafka Cluster (and with CloudKarafka even easier) • Note: managing a production grade cluster is not so easy Microservices & Apache Kafka - 24 maart 2021
  • 82. Classificatie: vertrouwelijk Microservices in real life – with Node & Dapr.io you are invited to come do an internship and explore job opportunities with us! [email protected] | technology.amis.nl | @lucasjellema | lucas-jellema

Editor's Notes

  • #2: Wat is een microservice? (waarom, problemen met monolitische applicaties, hoe microservice architectuur, generieke voorzieningen & platform voor microservices, data & events als glue tussen microservices) Hier alvast stilstaan bij het belang van een event broker en een korte intro van Kafka (meer in college 2) Implementatie van microservices: afhandelen van http requests, consumeren en publiceren van events, doen van http calls:  wat zijn activiteiten die iedere microservice moet uitvoeren? (state mgt, pub/sub, secrets, config mgt, aanroepen 3rd party (cloud) services, ..) Introductie en demo van Dapr.io framework – de personal assistant die iedere applicatie eenvoudig laat aansluiten op generieke voorzieningen én die applicaties (microservices) met elkaar laat interacteren op ontkoppelde wijze; note: ik zal wijzen op de ondersteuning in Dapr.io voor diverse technologieën zoals RabbitMQ, MySQL, Redis Handson met Dapr – meegeleverde applicaties in Java en C# Zelf implementeren van microservice – introductie van NodeJS ; Handson: afbouwen eenvoudige services in NodeJs en via Dapr.io interactie met elkaar en met generieke voorzieningen
  • #37: https://cwiki.apache.org/confluence/display/KAFKA/Clients
  • #38: https://cwiki.apache.org/confluence/display/KAFKA/Clients
  • #39: https://cwiki.apache.org/confluence/display/KAFKA/Clients
  • #57: Events are immutable facts Current state (active record) is derived from sum of events Read optimized aggregates are created for specific use case – based on events and rebuildable at any time
  • #58: Events are immutable facts Current state (active record) is derived from sum of events Read optimized aggregates are created for specific use case – based on events and rebuildable at any time