Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Kiki Carter
Enterprise Architect
May 2017
Event Sourcing and CQRS in 20
minutes with Akka & Java 8
Lightbend
Headquarters in
San Francisco &
Lausanne,
Switzerland
>2 million
downloads
Lightbend
Reactive
Platform
Originato...
About me
Some things I like Some things I don’t like
IG: @thatskiki
Heights
Wild wildlife
Unintentional Sharing
These thin...
Why are we talking about this
anyway?
Not really *new* buzzwords
Legacy App Modernization
(is a thing again)
Distributed Systems(for real this
time)
A system of
autonomous
collaborative distributed
services
Autonomy
From Greek Auto-nomos:
auto meaning self
nomos meaning law
Leading the
way:
Promise
Theory
Think in Promises
not Obligations
“Autonomy makes information
local, leading to greater certainty
and stability”
- In Search for Certainty by Mark Burgess
No one can tell my story better than
I can…
Obligations diverge into unpredictable outcomes from definite
beginnings ⇒ decreased certainty
Promises converge towards a...
Decreased Certainty IRL
An Autonomous
Service can only
Promise its own
Behavior
How do we get there? (irl)
Data Center A
eCommerce
server
eCommerce
server
eCommerce
server
Database Database
Data Center B
eCommerce
server
eCommerc...
Enter Distributed Scaling
User
order
cart
Shop
data
User
order
cart
Shop
data
Scale by “stateless services”
Eat your broccoli!
I’m eating it!
I’m eating it!
I’m eating it!
User
order
cart
Shop
data
User
order
cart
Shop
data
data
data
data
But wait, there’s more!
User
order
cart
Shop
data
User
order
cart
Shop
data
Shareddomainobjs
User
order
cart
Shop
data
User
order
cart
Shop
data
data
data
data
Shareddomainobjs
User
order
cart
Shop
data
User
order
cart
Shop
data
data
data
data
May not be accurate – probably isn’t
It’s not the things, it’s the things
that happen
#facts
Define with events
Example: Instead of a shop
service, events that happen within
the shopping context
What happens to our state?
First: A true story
Enter Event Sourcing
Shopping context
data data
events
events
events
Stateless Gateway
entity entity entity
state state state
Akka
Persistence
...
In Akka Persistence: key structures
Command
Events
State
Events
Events
Inside your persistent Actor:
Anatomy:
Anatomy:
Recovery, a first class concept:
Why bring cqrs along?
The world revolves around events:
command
command
command
eventevent
eventeventevent
event
state Snapshots | Events
Read-side
representation
queries
Read-si...
And if you need to share facts
outside of your context boundary…
command
command
command
eventevent
eventeventevent
event
state Snapshots | Events
distributed
pub-subRead-only
command
Rea...
Technology Implications
• The storage system becomes an additive only architecture
• Append-only architectures distribute
...
Business Implications
• Criteria is tracked from inception as an event stream
• You can answer questions form the origin o...
Questions?
An Open Source framework for building micro service systems
Rate of change with levels of
abstraction
Low level languages
High level languages
Libraries / packages
Application Framew...
Shopping context
data data
events
events
events
Stateless Gateway
entity entity entity
state state state
Akka
Persistence
...
Web Application Framework
Concurrency Toolkit  Runtime
Thin, powerful abstraction over
Microservice system framework
Other...
Enterprise Challenge
Build faster
Maintain architectural integrity as you move fast
Enterprise software development is a h...
Too Many Choices
Analysis Paralysis
Challenge
Lagom makes reasonable choices for
you.
It’s built on message-driven technology
that’s highly responsive, elastic and faul...
Lagom Components
Akka – Persistence, PubSub, Cluster, Streaming Async Services
Play Framework – Web framework
Cassandra – ...
Difficult to Consistently Scale
Architectural Integrity
Challenge
Lagom consistently applies
patterns for Reactive System
Building
Architectural Principles Enforced by Lagom
Single Responsibility
Principle
Service Oriented
Architecture
Encapsulation
Hex...
Asynchronous
& Non
Blocking
Event
Sourcing
Command
query
responsibility
segregation
Eventual
Consistency
Domain
Driven Des...
Example: Event Sourcing
Experts Required
Challenge
Experts Required
You don’t need “Lagom developers” just Scala or Java developers
willing to apply Lagom semantics.
Must Protect Developer
Productivity
Challenge
Practical Productivity
Scala
&
Java API
Use Any IDE
Quick Start
w/ Batteries
Included
Hot Reload
& Single
Command
to Runal...
Unplanned Complexity or Chaos
Challenge
Monolith
with many
moving
parts.
You cannot simply
break the seal and
expect everything
to function correctly
Lagom minimizes chaos through
isolation, autonomous services
Lagom Encourages and Enables
You to Contain Mutable State &
Publish Facts
Example:
State contained
Publish Facts
Lagom Allows You to Untangle
Read & Write Models with CQRS &
Event Sourcing
Lagom uses asynchronous
messaging, asynchronous IO &
distributed persistence patterns
client
command
command
node
node
node
node
Reactive programming
RES
T
messaging streaming
Stateless Behavior
node
Reactive...
All or Nothing
This and Everything
Challenge
Lagom & your Legacy
• Language agnostic communication with external services
• Safe Interaction with legacy systems via ci...
With Withoutor
Governance, Templates, Ref Apps,
Documentation, scaling architecture
expertise, etc.
Boot
Reactor
Kafka
Cas...
In Summary
In order to keep up with the pace of change and
maintain architectural integrity as you move, try
using a frame...
Try Lagom
• www.lagomframework.com , https://github.com/lagom
• Basic example “Hello World” -
https://www.lagomframework.c...
Questions?
Event Sourcing in less than 20 minutes - With Akka and Java 8
Próxima SlideShare
Cargando en…5
×

Event Sourcing in less than 20 minutes - With Akka and Java 8

6.163 visualizaciones

Publicado el

Event Sourcing and CQRS are the new buzz words for a while now. Driven by the modernization needs of old monolithic applications, the industry's march towards more modular applications through microservices seems unstoppable. But you don't have to use latest buzzy microservices frameworks to build rock solid and modular applications. You can also use proven technology like Akka. This talk gives an overview about event sourcing and how to achieve this with Akka and Java 8. You'll learn how CQRS fits into the puzzle and what other technologies are there to help you build state of the art applications.

Publicado en: Tecnología

Event Sourcing in less than 20 minutes - With Akka and Java 8

  1. 1. Kiki Carter Enterprise Architect May 2017 Event Sourcing and CQRS in 20 minutes with Akka & Java 8
  2. 2. Lightbend Headquarters in San Francisco & Lausanne, Switzerland >2 million downloads Lightbend Reactive Platform Originators of the Reactive Manifesto >17,000 signers Reactive Experts in 20 Countries around the globe
  3. 3. About me Some things I like Some things I don’t like IG: @thatskiki Heights Wild wildlife Unintentional Sharing These things
  4. 4. Why are we talking about this anyway?
  5. 5. Not really *new* buzzwords
  6. 6. Legacy App Modernization (is a thing again)
  7. 7. Distributed Systems(for real this time)
  8. 8. A system of autonomous collaborative distributed services
  9. 9. Autonomy From Greek Auto-nomos: auto meaning self nomos meaning law
  10. 10. Leading the way: Promise Theory
  11. 11. Think in Promises not Obligations
  12. 12. “Autonomy makes information local, leading to greater certainty and stability” - In Search for Certainty by Mark Burgess
  13. 13. No one can tell my story better than I can…
  14. 14. Obligations diverge into unpredictable outcomes from definite beginnings ⇒ decreased certainty Promises converge towards a definite outcome from unpredictable beginnings ⇒ improved certainty
  15. 15. Decreased Certainty IRL
  16. 16. An Autonomous Service can only Promise its own Behavior
  17. 17. How do we get there? (irl)
  18. 18. Data Center A eCommerce server eCommerce server eCommerce server Database Database Data Center B eCommerce server eCommerce server eCommerce server Database Database Heritage Distributed Systems
  19. 19. Enter Distributed Scaling
  20. 20. User order cart Shop data User order cart Shop data Scale by “stateless services”
  21. 21. Eat your broccoli!
  22. 22. I’m eating it!
  23. 23. I’m eating it!
  24. 24. I’m eating it!
  25. 25. User order cart Shop data User order cart Shop data data data data
  26. 26. But wait, there’s more!
  27. 27. User order cart Shop data User order cart Shop data Shareddomainobjs
  28. 28. User order cart Shop data User order cart Shop data data data data Shareddomainobjs
  29. 29. User order cart Shop data User order cart Shop data data data data May not be accurate – probably isn’t
  30. 30. It’s not the things, it’s the things that happen #facts
  31. 31. Define with events
  32. 32. Example: Instead of a shop service, events that happen within the shopping context
  33. 33. What happens to our state?
  34. 34. First: A true story
  35. 35. Enter Event Sourcing
  36. 36. Shopping context data data events events events Stateless Gateway entity entity entity state state state Akka Persistence commands
  37. 37. In Akka Persistence: key structures Command Events State Events Events
  38. 38. Inside your persistent Actor:
  39. 39. Anatomy:
  40. 40. Anatomy:
  41. 41. Recovery, a first class concept:
  42. 42. Why bring cqrs along?
  43. 43. The world revolves around events:
  44. 44. command command command eventevent eventeventevent event state Snapshots | Events Read-side representation queries Read-side processing Read-only command
  45. 45. And if you need to share facts outside of your context boundary…
  46. 46. command command command eventevent eventeventevent event state Snapshots | Events distributed pub-subRead-only command Read-side representation queries Read-side processing Service A Service B
  47. 47. Technology Implications • The storage system becomes an additive only architecture • Append-only architectures distribute • Far fewer locks to deal with • Horizontal Partitioning is difficult for a relational model
  48. 48. Business Implications • Criteria is tracked from inception as an event stream • You can answer questions form the origin of the system • You can answer questions not asked yet! • Natural audit log
  49. 49. Questions?
  50. 50. An Open Source framework for building micro service systems
  51. 51. Rate of change with levels of abstraction Low level languages High level languages Libraries / packages Application Frameworks Application Networking System Building Frameworks Rate of change Levels of abstraction
  52. 52. Shopping context data data events events events Stateless Gateway entity entity entity state state state Akka Persistence is focused in the entity commands
  53. 53. Web Application Framework Concurrency Toolkit Runtime Thin, powerful abstraction over Microservice system framework Other curated tools, architectural principles and patterns used for building reactive microservice systems
  54. 54. Enterprise Challenge Build faster Maintain architectural integrity as you move fast Enterprise software development is a high stakes game Success is high reward, failure is high risk
  55. 55. Too Many Choices Analysis Paralysis Challenge
  56. 56. Lagom makes reasonable choices for you. It’s built on message-driven technology that’s highly responsive, elastic and fault- tolerant. It’s Reactive.
  57. 57. Lagom Components Akka – Persistence, PubSub, Cluster, Streaming Async Services Play Framework – Web framework Cassandra – managing data persistence Guice – dependency injection SLF4J & Logback – Logging Typesafe Config – configuration JSON Serialization – Play JSON (Scala) Jackson (Java) Service Gateway Message Broker - Kafka
  58. 58. Difficult to Consistently Scale Architectural Integrity Challenge
  59. 59. Lagom consistently applies patterns for Reactive System Building
  60. 60. Architectural Principles Enforced by Lagom Single Responsibility Principle Service Oriented Architecture Encapsulation Hexagonal Architecture
  61. 61. Asynchronous & Non Blocking Event Sourcing Command query responsibility segregation Eventual Consistency Domain Driven Design (Bounded Contexts, Context Maps, Aggregate Entities) Service Locator Discovery Edge Service Lagom Design Patterns Key Patterns Required when building distributed reactive microservice systems Circuit Breaker
  62. 62. Example: Event Sourcing
  63. 63. Experts Required Challenge
  64. 64. Experts Required You don’t need “Lagom developers” just Scala or Java developers willing to apply Lagom semantics.
  65. 65. Must Protect Developer Productivity Challenge
  66. 66. Practical Productivity Scala & Java API Use Any IDE Quick Start w/ Batteries Included Hot Reload & Single Command to Runall Developer productivity is a core feature of the Framework
  67. 67. Unplanned Complexity or Chaos Challenge
  68. 68. Monolith with many moving parts.
  69. 69. You cannot simply break the seal and expect everything to function correctly
  70. 70. Lagom minimizes chaos through isolation, autonomous services
  71. 71. Lagom Encourages and Enables You to Contain Mutable State & Publish Facts
  72. 72. Example: State contained Publish Facts
  73. 73. Lagom Allows You to Untangle Read & Write Models with CQRS & Event Sourcing
  74. 74. Lagom uses asynchronous messaging, asynchronous IO & distributed persistence patterns
  75. 75. client command command node node node node Reactive programming RES T messaging streaming Stateless Behavior node Reactive programming Stateful Entity Write model event log DS Event (fact) Event (fact) Read model query db DS Event (fact) Event (fact) Service discovery Service gateway Authentication … command command command ReactiveSystem
  76. 76. All or Nothing This and Everything Challenge
  77. 77. Lagom & your Legacy • Language agnostic communication with external services • Safe Interaction with legacy systems via circuit breakers • No need to tear everything down and start over • Embraces polyglot systems
  78. 78. With Withoutor Governance, Templates, Ref Apps, Documentation, scaling architecture expertise, etc. Boot Reactor Kafka Cassandra Netflix Patterns asynchronous REST streaming CQRS Event Sourcing Eventual consistency DDD Service locator Java Eventuate Axon Spring Cloud … Play Akka Kafka CassandraScala Patterns asynchronous REST streaming CQRS Event Sourcing Eventual consistency DDD Service locator Java
  79. 79. In Summary In order to keep up with the pace of change and maintain architectural integrity as you move, try using a framework that provides an abstraction above the application level – at the system level. ….and what if you don’t?
  80. 80. Try Lagom • www.lagomframework.com , https://github.com/lagom • Basic example “Hello World” - https://www.lagomframework.com/get-started-scala.html • More robust example “Online Auction” - https://github.com/lagom/online-auction-scala • Ask me for a demo: • kiki@lightbend.com • Twitter: @kikisworldrace
  81. 81. Questions?

×