This is a presentation I gave at SF Scala.
I describe the motivations for having a pattern language for microservices.
I then describe how to build event-driven microservices using event sourcing and CQRS.
I show some Java and Scala code examples.
4. @crichardson
About Chris
Founder of a startup that is creating
a platform that makes it easy for
application developers write
microservices
(http://eventuate.io)
6. Agenda
Why a pattern language for microservices?
Monolith architecture vs. microservices
Developing microservices with event sourcing and CQRS
Microservices in Java
Microservices in Scala
Example: real-time, collaborative Kanban board application
8. @crichardson
Yet 30 years later….
If you __________________
a puppy will die
Therefore
you must _______________
9. @crichardson
Quiz - fill in the blanks….
mutate state
use monads
use objects
use functions
block a thread
use async.
make a REST call
send a messageuse Spring
use ….
10. @crichardson
How we make decisions
Decide
using
emotions
Rationalize with
our intellect
http://en.wikipedia.org/wiki/Mahout
12. @crichardson
The structure of a pattern
Resulting context
aka the situation
Name
Context
Problem
Related patterns
(conflicting) issues
etc to address
Forces
Solution
14. Agenda
Why a pattern language for microservices?
Monolith architecture vs. microservices
Developing microservices with event sourcing and CQRS
Microservices in Java
Microservices in Scala
Example: real-time, collaborative Kanban board application
21. Agenda
Why a pattern language for microservices?
Monolith architecture vs. microservices
Developing microservices with event sourcing and CQRS
Microservices in Java
Microservices in Scala
Example: real-time, collaborative Kanban board application
22. Data management patterns
Database per
Service
Event-driven
architecture
Shared
database
Event
sourcing
Transaction
log tailing
Database
triggers
Application
events
CQRS
Database architecture
24. @crichardson
Customer management
How to maintain invariants?
Order management
Order Service
placeOrder()
Customer Service
updateCreditLimit()
Customer
creditLimit
...
has ordersbelongs toOrder
total
Invariant:
sum(open order.total) <= customer.creditLimit
?
29. @crichardson
Replay events to recreate
state
Order
state
OrderCreated(…)
OrderAccepted(…)
OrderShipped(…)
Events
Periodically snapshot to avoid loading all events
35. Multiple flavors of client
frameworks
“Traditional Java” mutable object-oriented domain objects
https://github.com/cer/event-sourcing-examples/tree/master/
java-spring
Functional Scala with immutable domain objects
https://github.com/cer/event-sourcing-using-scala-typeclasses
Hybrid OO/Functional Scala with immutable domain objects
https://github.com/cer/event-sourcing-examples/tree/master/
scala-spring
36. Agenda
Why a pattern language for microservices?
Monolith architecture vs. microservices
Developing microservices with event sourcing and CQRS
Microservices in Java
Microservices in Scala
Example: real-time, collaborative Kanban board application
48. Agenda
Why a pattern language for microservices?
Monolith architecture vs. microservices
Developing microservices with event sourcing and CQRS
Microservices in Java
Microservices in Scala
Example: real-time, collaborative Kanban board application
54. Agenda
Why a pattern language for microservices?
Monolith architecture vs. microservices
Developing microservices with event sourcing and CQRS
Microservices in Java
Microservices in Scala
Example: real-time, collaborative Kanban board application
58. Summary
Microservices are not a silver bullet but they are the
best choice for large/complex applications
Use an event-driven microservices architecture
Build services using event sourcing + CQRS
Using a language/framework specific programming
model