SlideShare a Scribd company logo
Event Sourcing
with Apache Pulsar
& Quarkus
David Kjerrumgaard | Developer Advocate
streamnative.io
● Apache Pulsar Committer | Author of Pulsar In Action
● Former Principal Software Engineer on Splunk’s messaging team
that is responsible for Splunk’s internal Pulsar-as-a-Service
platform.
● Former Director of Solution Architecture at Streamlio.
David
Kjerrumgaard
Developer Advocate
streamnative.io
● Author of Pulsar In Action.
● Co-Author of Practical Hive
David Kjerrumgaard
Author
https://streamnative.io/download/manning-ebook-apache-pulsar-in-action
streamnative.io
Application
Development
Trends
streamnative.io
• DevOps automates the process of software delivery & infrastructure
changes.
• ContinuousDeliveryenables applications to released quickly and
reliably with less risk.
• Containersprovide light-weight virtualization by dynamically
dividing a single server into one or more isolated containers.
• Microservices is an architectural approach to building an
application as a collection of small independent services that
communicate with one another.
* Image src: https://pivotal.io/cloud-native
streamnative.io
• Componentization via Services
• Organizedaround Business Capabilities
• Products notProjects
• SmartEndpoints & Dumb Pipes
• Decentralized Governance
• DecentralizedDataManagement
• Infrastructure Automation
• DesignforFailure
• Evolutionary Design
Microservice
Characteristics
streamnative.io
Decentralized Data Management
● At the most abstract level, the conceptual model of the world
differs between microservices.
● Monolithic applications prefer a single logical database for
persistent data.
● Microservices prefer letting each service manage its own
database, either different instances of the same database
technology, or entirely different database systems - an approach
called Polyglot Persistence.
Polyglot Persistence
* Image src: https://martinfowler.com
streamnative.io
Design for Failure
● Since microservices can fail at any time, it's important to be able
to automatically restore service.
● For partial failures scenarios, this requires processing all the
events that occurred while the service was offline in order to
update the internal database state.
● For complete failure events, the internal database must be
reconstructed from scratch.
streamnative.io
• Event Sourcing ensures that all changes to
application state are stored as a sequence
of events in a log.
• We can use the event log to reconstruct
past states, and as a foundation adjust the
state to cope with retroactive changes.
• Supports Polyglot Persistence by allowing
each service to build it own database
based on the events
• In the event of failure, the service state can
be rebuilt from the events in the event log.
Event Sourcing
streamnative.io
State Based vs. Event Based Data Models
State-Based:
● Record the position/state at any
point in time using a database and
synchronous calls.
● Supports full CRUD semantics.
Reads/Writes on the same data
source.
streamnative.io
State Based Data Model
streamnative.io
State Based vs. Event Based Data Models
State-Based:
● Record the position/state at any
point in time using a database and
synchronous calls.
● Supports full CRUD semantics.
Reads/Writes on the same data
source.
Event-Based:
● Records all events in an immutable
sequence.
● Each event represents a transition
from one state to another.
● Current state is the culmination of all
the events up to the given point in
time.
streamnative.io
Event Based Data Model
Complete Rebuild
We can discard the application state
completely and rebuild it by re-running the
events from the event log on an empty
application.
Temporal Queries
We can determine the application state at any
point in time. Notionally we do this by starting
with a blank state and rerunning the events up
to a particular time or event.
Event Replay
If we find a past event was incorrect, we can
compute the consequences by reversing it
and later events by replaying the new event
and later events.
Correcting Bad Data/Code
If a code update introduces an error into the
data, e.g., bad calculation. We can correct the
data by replaying the data through a “good”
version of the code.
Event Reversal
This helps account for the lack of distributed
transactions across microservices. The
reversal of an event to "add $10 to account
123", would be "subtract 10$ from account
123"
Event Sourcing Benefits
Event Sourcing Architecture
Apache Pulsar is a Cloud-Native Messaging and
Event-Streaming Platform.
Pulsar Pub/Sub Model
Producer Consumer
Publisher sends data and
doesn't know about the
subscribers or their status.
All interactions go through
Pulsar, and it handles all
communication.
Subscriber receives data from
publisher and never directly
interacts with it.
Topic
Topic
Unified Messaging Model
Simplify your data infrastructure and enable
new use cases with queuing and streaming
capabilities in one platform.
Multi-tenancy
Enable multiple user groups to share the
same cluster, either via access control, or in
entirely different namespaces.
Scalability
Decoupled data computing and storage
enable horizontal scaling to handle data scale
and management complexity.
Geo-replication
Support for multi-datacenter replication with
both asynchronous and synchronous
replication for built-in disaster recovery.
Tiered storage
Enable historical data to be offloaded to cloud-
native storage and store event streams for
indefinite periods of time.
Pulsar Benefits
Why ApachePulsarfor Event Sourcing?
Event Streaming
Platform
Guaranteed
Message Delivery Resiliency Infinite
Scalability
Apache Quarkus is is a full-stack, Kubernetes-
native Java framework.
Container First
Amazingly fast boot time, incredibly low
memory offering near instant scale up and
high-density memory utilization in container
orchestration platforms like Kubernetes.
Unifies imperative and reactive
Combines both the familiar imperative code
and the reactive programming styles when
developing applications.
Community & Standards
Provides a cohesive, full-stack framework by
leveraging a growing list of best-of-breed
libraries that you love and use. All wired on a
standard backbone.
Cloud Native
The combination of Quarkus and Kubernetes
provides an ideal environment for creating scalable,
fast, and lightweight applications.
Developer Joy
A cohesive platform for optimized developer joy
with unified configuration and no hassle native
executable generation. Zero config, live reload in
the blink of an eye..
Quarkus Benefits
Why Quarkus for Event Sourcing?
Reactive Programmingin
Java
Containerfirst Philosophy
Kubernetes Native Optimizedmemory
usage
Implementation
streamnative.io
Event Sourcing Application Architecture
streamnative.io
Update Driver Position
● Mobile app automatically sends position
update every 30 seconds with this
command.
● Command handler generates a new
“Driver location” event in response to this
message.
● Command handler performs additional
data enrichment.
streamnative.io
View #1: Assigned Driver Location
● Once a driver has been assigned to a
customer, we want to track the driver in
route.
● View comprised of the driver’s most
recent positions, which can be displayed
visually as a map.
● Solution: Use an exclusive subscription
and filter by driver id
streamnative.io
View #2: Analytics
● To help optimize driver placement, a
heat map of driver density per “grid” is
calculated.
● View is a map of grid_id’s and number
of drivers located within that grid.
● Solution: Use the Reader interface,
go back N minutes and recalculate.
Demo Commands & Views
Code: git@github.com:david-streamlio/GottaEat-UI.git
streamnative.io
Key Takeaways
➔ Event Sourcing is great for storing
data that needs to be consumed in
different ways.
➔ Apache Pulsar is a great option for
event-based storage.
➔ Pulsar’s API can be used to create
materialized views of event data.
streamnative.io
[Webinar]
Building Microservices
Watch Now Learn More
[Blog post]
Event-Driven Microservices
Now Available
On-Demand Pulsar
Training
Academy.StreamNative.io
32
Hosted by
Save Your Spot Now
Use code SUMMIT20
to get 20% off.
Pulsar Summit
San Francisco
Hotel Nikko
August 18 2022
Summit Highlights:
● 5 Keynotes
● 12 Breakout Sessions
● 1 Amazing Happy Hour
Speakers from:
Let’s Keep
in Touch!
David Kjerrumgaard
Developer Advocate
@davidkjerrumga1
https://www.linkedin.com/in/davidkj/
https://github.com/davidkj
Q&A

More Related Content

PDF
apidays New York 2022 - Leveraging Event Streaming to Super-Charge your Busin...
PDF
Cloud lunch and learn real-time streaming in azure
PDF
Osacon 2021 hello hydrate! from stream to clickhouse with apache pulsar and...
PDF
INTERFACE by apidays 2023 - Leveraging Event Streaming to Super-Charge your B...
PDF
Using FLiP with InfluxDB for EdgeAI IoT at Scale 2022
PDF
Using FLiP with influxdb for edgeai iot at scale 2022
PDF
What We Learned From Building a Modern Messaging and Streaming System for Cloud
PDF
Event-Driven Applications Done Right - Pulsar Summit SF 2022
apidays New York 2022 - Leveraging Event Streaming to Super-Charge your Busin...
Cloud lunch and learn real-time streaming in azure
Osacon 2021 hello hydrate! from stream to clickhouse with apache pulsar and...
INTERFACE by apidays 2023 - Leveraging Event Streaming to Super-Charge your B...
Using FLiP with InfluxDB for EdgeAI IoT at Scale 2022
Using FLiP with influxdb for edgeai iot at scale 2022
What We Learned From Building a Modern Messaging and Streaming System for Cloud
Event-Driven Applications Done Right - Pulsar Summit SF 2022

Similar to Data Con LA 2022 - Event Sourcing with Apache Pulsar and Apache Quarkus (20)

PDF
Big data conference europe real-time streaming in any and all clouds, hybri...
PDF
Open keynote_carolyn&matteo&sijie
PDF
Designing Event-Driven Applications with Apache NiFi, Apache Flink, Apache Sp...
PDF
Big mountain data and dev conference apache pulsar with mqtt for edge compu...
PDF
Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...
PDF
Microservices, containers and event driven architecture - key factors in agil...
PPTX
Building an Event Streaming Architecture with Apache Pulsar
PDF
Serverless Event Streaming Applications as Functionson K8
PPTX
Do You Really Need to Evolve From Monitoring to Observability?
PDF
(Current22) Let's Monitor The Conditions at the Conference
PDF
Let’s Monitor Conditions at the Conference With Timothy Spann & David Kjerrum...
PPTX
Increasing agility with php and kafka
PPTX
Using Event Streams in Serverless Applications
PDF
Apache Pulsar Overview
PDF
The resurgence of event driven architecture
PDF
Music city data Hail Hydrate! from stream to lake
PDF
An eventful tour from enterprise integration to serverless and functions
PDF
Apache Pulsar @Splunk
PPTX
Microservices, containers and event driven architecture - key factors in agil...
PDF
Microservices, containers and event driven architecture - key factors in agil...
Big data conference europe real-time streaming in any and all clouds, hybri...
Open keynote_carolyn&matteo&sijie
Designing Event-Driven Applications with Apache NiFi, Apache Flink, Apache Sp...
Big mountain data and dev conference apache pulsar with mqtt for edge compu...
Ten reasons to choose Apache Pulsar over Apache Kafka for Event Sourcing_Robe...
Microservices, containers and event driven architecture - key factors in agil...
Building an Event Streaming Architecture with Apache Pulsar
Serverless Event Streaming Applications as Functionson K8
Do You Really Need to Evolve From Monitoring to Observability?
(Current22) Let's Monitor The Conditions at the Conference
Let’s Monitor Conditions at the Conference With Timothy Spann & David Kjerrum...
Increasing agility with php and kafka
Using Event Streams in Serverless Applications
Apache Pulsar Overview
The resurgence of event driven architecture
Music city data Hail Hydrate! from stream to lake
An eventful tour from enterprise integration to serverless and functions
Apache Pulsar @Splunk
Microservices, containers and event driven architecture - key factors in agil...
Microservices, containers and event driven architecture - key factors in agil...
Ad

More from Data Con LA (20)

PPTX
Data Con LA 2022 Keynotes
PPTX
Data Con LA 2022 Keynotes
PDF
Data Con LA 2022 Keynote
PPTX
Data Con LA 2022 - Startup Showcase
PPTX
Data Con LA 2022 Keynote
PDF
Data Con LA 2022 - Using Google trends data to build product recommendations
PPTX
Data Con LA 2022 - AI Ethics
PDF
Data Con LA 2022 - Improving disaster response with machine learning
PDF
Data Con LA 2022 - What's new with MongoDB 6.0 and Atlas
PDF
Data Con LA 2022 - Real world consumer segmentation
PPTX
Data Con LA 2022 - Modernizing Analytics & AI for today's needs: Intuit Turbo...
PPTX
Data Con LA 2022 - Moving Data at Scale to AWS
PDF
Data Con LA 2022 - Collaborative Data Exploration using Conversational AI
PDF
Data Con LA 2022 - Why Database Modernization Makes Your Data Decisions More ...
PDF
Data Con LA 2022 - Intro to Data Science
PDF
Data Con LA 2022 - How are NFTs and DeFi Changing Entertainment
PPTX
Data Con LA 2022 - Why Data Quality vigilance requires an End-to-End, Automat...
PPTX
Data Con LA 2022-Perfect Viral Ad prediction of Superbowl 2022 using Tease, T...
PPTX
Data Con LA 2022- Embedding medical journeys with machine learning to improve...
PPTX
Data Con LA 2022 - Data Streaming with Kafka
Data Con LA 2022 Keynotes
Data Con LA 2022 Keynotes
Data Con LA 2022 Keynote
Data Con LA 2022 - Startup Showcase
Data Con LA 2022 Keynote
Data Con LA 2022 - Using Google trends data to build product recommendations
Data Con LA 2022 - AI Ethics
Data Con LA 2022 - Improving disaster response with machine learning
Data Con LA 2022 - What's new with MongoDB 6.0 and Atlas
Data Con LA 2022 - Real world consumer segmentation
Data Con LA 2022 - Modernizing Analytics & AI for today's needs: Intuit Turbo...
Data Con LA 2022 - Moving Data at Scale to AWS
Data Con LA 2022 - Collaborative Data Exploration using Conversational AI
Data Con LA 2022 - Why Database Modernization Makes Your Data Decisions More ...
Data Con LA 2022 - Intro to Data Science
Data Con LA 2022 - How are NFTs and DeFi Changing Entertainment
Data Con LA 2022 - Why Data Quality vigilance requires an End-to-End, Automat...
Data Con LA 2022-Perfect Viral Ad prediction of Superbowl 2022 using Tease, T...
Data Con LA 2022- Embedding medical journeys with machine learning to improve...
Data Con LA 2022 - Data Streaming with Kafka
Ad

Recently uploaded (20)

PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PDF
annual-report-2024-2025 original latest.
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
Introduction to machine learning and Linear Models
PDF
[EN] Industrial Machine Downtime Prediction
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PDF
.pdf is not working space design for the following data for the following dat...
PDF
Mega Projects Data Mega Projects Data
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
Qualitative Qantitative and Mixed Methods.pptx
PPTX
1_Introduction to advance data techniques.pptx
PPTX
Market Analysis -202507- Wind-Solar+Hybrid+Street+Lights+for+the+North+Amer...
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
STERILIZATION AND DISINFECTION-1.ppthhhbx
PPT
Reliability_Chapter_ presentation 1221.5784
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
oil_refinery_comprehensive_20250804084928 (1).pptx
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
annual-report-2024-2025 original latest.
IBA_Chapter_11_Slides_Final_Accessible.pptx
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Introduction to machine learning and Linear Models
[EN] Industrial Machine Downtime Prediction
Business Ppt On Nestle.pptx huunnnhhgfvu
.pdf is not working space design for the following data for the following dat...
Mega Projects Data Mega Projects Data
Miokarditis (Inflamasi pada Otot Jantung)
Qualitative Qantitative and Mixed Methods.pptx
1_Introduction to advance data techniques.pptx
Market Analysis -202507- Wind-Solar+Hybrid+Street+Lights+for+the+North+Amer...
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
climate analysis of Dhaka ,Banglades.pptx
STERILIZATION AND DISINFECTION-1.ppthhhbx
Reliability_Chapter_ presentation 1221.5784
Recruitment and Placement PPT.pdfbjfibjdfbjfobj

Data Con LA 2022 - Event Sourcing with Apache Pulsar and Apache Quarkus

  • 1. Event Sourcing with Apache Pulsar & Quarkus David Kjerrumgaard | Developer Advocate
  • 2. streamnative.io ● Apache Pulsar Committer | Author of Pulsar In Action ● Former Principal Software Engineer on Splunk’s messaging team that is responsible for Splunk’s internal Pulsar-as-a-Service platform. ● Former Director of Solution Architecture at Streamlio. David Kjerrumgaard Developer Advocate
  • 3. streamnative.io ● Author of Pulsar In Action. ● Co-Author of Practical Hive David Kjerrumgaard Author https://streamnative.io/download/manning-ebook-apache-pulsar-in-action
  • 5. streamnative.io • DevOps automates the process of software delivery & infrastructure changes. • ContinuousDeliveryenables applications to released quickly and reliably with less risk. • Containersprovide light-weight virtualization by dynamically dividing a single server into one or more isolated containers. • Microservices is an architectural approach to building an application as a collection of small independent services that communicate with one another. * Image src: https://pivotal.io/cloud-native
  • 6. streamnative.io • Componentization via Services • Organizedaround Business Capabilities • Products notProjects • SmartEndpoints & Dumb Pipes • Decentralized Governance • DecentralizedDataManagement • Infrastructure Automation • DesignforFailure • Evolutionary Design Microservice Characteristics
  • 7. streamnative.io Decentralized Data Management ● At the most abstract level, the conceptual model of the world differs between microservices. ● Monolithic applications prefer a single logical database for persistent data. ● Microservices prefer letting each service manage its own database, either different instances of the same database technology, or entirely different database systems - an approach called Polyglot Persistence.
  • 8. Polyglot Persistence * Image src: https://martinfowler.com
  • 9. streamnative.io Design for Failure ● Since microservices can fail at any time, it's important to be able to automatically restore service. ● For partial failures scenarios, this requires processing all the events that occurred while the service was offline in order to update the internal database state. ● For complete failure events, the internal database must be reconstructed from scratch.
  • 10. streamnative.io • Event Sourcing ensures that all changes to application state are stored as a sequence of events in a log. • We can use the event log to reconstruct past states, and as a foundation adjust the state to cope with retroactive changes. • Supports Polyglot Persistence by allowing each service to build it own database based on the events • In the event of failure, the service state can be rebuilt from the events in the event log. Event Sourcing
  • 11. streamnative.io State Based vs. Event Based Data Models State-Based: ● Record the position/state at any point in time using a database and synchronous calls. ● Supports full CRUD semantics. Reads/Writes on the same data source.
  • 13. streamnative.io State Based vs. Event Based Data Models State-Based: ● Record the position/state at any point in time using a database and synchronous calls. ● Supports full CRUD semantics. Reads/Writes on the same data source. Event-Based: ● Records all events in an immutable sequence. ● Each event represents a transition from one state to another. ● Current state is the culmination of all the events up to the given point in time.
  • 15. Complete Rebuild We can discard the application state completely and rebuild it by re-running the events from the event log on an empty application. Temporal Queries We can determine the application state at any point in time. Notionally we do this by starting with a blank state and rerunning the events up to a particular time or event. Event Replay If we find a past event was incorrect, we can compute the consequences by reversing it and later events by replaying the new event and later events. Correcting Bad Data/Code If a code update introduces an error into the data, e.g., bad calculation. We can correct the data by replaying the data through a “good” version of the code. Event Reversal This helps account for the lack of distributed transactions across microservices. The reversal of an event to "add $10 to account 123", would be "subtract 10$ from account 123" Event Sourcing Benefits
  • 17. Apache Pulsar is a Cloud-Native Messaging and Event-Streaming Platform.
  • 18. Pulsar Pub/Sub Model Producer Consumer Publisher sends data and doesn't know about the subscribers or their status. All interactions go through Pulsar, and it handles all communication. Subscriber receives data from publisher and never directly interacts with it. Topic Topic
  • 19. Unified Messaging Model Simplify your data infrastructure and enable new use cases with queuing and streaming capabilities in one platform. Multi-tenancy Enable multiple user groups to share the same cluster, either via access control, or in entirely different namespaces. Scalability Decoupled data computing and storage enable horizontal scaling to handle data scale and management complexity. Geo-replication Support for multi-datacenter replication with both asynchronous and synchronous replication for built-in disaster recovery. Tiered storage Enable historical data to be offloaded to cloud- native storage and store event streams for indefinite periods of time. Pulsar Benefits
  • 20. Why ApachePulsarfor Event Sourcing? Event Streaming Platform Guaranteed Message Delivery Resiliency Infinite Scalability
  • 21. Apache Quarkus is is a full-stack, Kubernetes- native Java framework.
  • 22. Container First Amazingly fast boot time, incredibly low memory offering near instant scale up and high-density memory utilization in container orchestration platforms like Kubernetes. Unifies imperative and reactive Combines both the familiar imperative code and the reactive programming styles when developing applications. Community & Standards Provides a cohesive, full-stack framework by leveraging a growing list of best-of-breed libraries that you love and use. All wired on a standard backbone. Cloud Native The combination of Quarkus and Kubernetes provides an ideal environment for creating scalable, fast, and lightweight applications. Developer Joy A cohesive platform for optimized developer joy with unified configuration and no hassle native executable generation. Zero config, live reload in the blink of an eye.. Quarkus Benefits
  • 23. Why Quarkus for Event Sourcing? Reactive Programmingin Java Containerfirst Philosophy Kubernetes Native Optimizedmemory usage
  • 26. streamnative.io Update Driver Position ● Mobile app automatically sends position update every 30 seconds with this command. ● Command handler generates a new “Driver location” event in response to this message. ● Command handler performs additional data enrichment.
  • 27. streamnative.io View #1: Assigned Driver Location ● Once a driver has been assigned to a customer, we want to track the driver in route. ● View comprised of the driver’s most recent positions, which can be displayed visually as a map. ● Solution: Use an exclusive subscription and filter by driver id
  • 28. streamnative.io View #2: Analytics ● To help optimize driver placement, a heat map of driver density per “grid” is calculated. ● View is a map of grid_id’s and number of drivers located within that grid. ● Solution: Use the Reader interface, go back N minutes and recalculate.
  • 29. Demo Commands & Views Code: git@github.com:david-streamlio/GottaEat-UI.git
  • 30. streamnative.io Key Takeaways ➔ Event Sourcing is great for storing data that needs to be consumed in different ways. ➔ Apache Pulsar is a great option for event-based storage. ➔ Pulsar’s API can be used to create materialized views of event data.
  • 31. streamnative.io [Webinar] Building Microservices Watch Now Learn More [Blog post] Event-Driven Microservices
  • 33. Hosted by Save Your Spot Now Use code SUMMIT20 to get 20% off. Pulsar Summit San Francisco Hotel Nikko August 18 2022 Summit Highlights: ● 5 Keynotes ● 12 Breakout Sessions ● 1 Amazing Happy Hour Speakers from:
  • 34. Let’s Keep in Touch! David Kjerrumgaard Developer Advocate @davidkjerrumga1 https://www.linkedin.com/in/davidkj/ https://github.com/davidkj
  • 35. Q&A