Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
TRANSACTIONAL EVENT SOURCING
USING SLICK
ADAM WARSKI
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
EVENT SOURCING?
▸ All changes in the system are captured as a sequence of events
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
WHY EVENT SOURCING?
▸ IT: Information Technology
▸ do not loose information!
▸ Audit...
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
ME + AUDIT = HIBERNATE ENVERS
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
ME
▸ coder @
▸ Lightbend consulting partner
▸ mainly Scala
▸ open-source: MacWire, E...
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
THE GOAL
▸ Get the benefits of Event Sourcing …
▸ … still being able to leverage RDBM...
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
OTHER APPROACHES
▸ Event Store (https://geteventstore.com)
▸ Akka Persistence (http:...
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
EVENTS
▸ Immutable
▸ Primary source of truth
▸ Past tense
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
EVENTS
▸ Payload: arbitrary json (case class)
▸ Event type (name of class)
▸ Aggrega...
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
HOW?
▸ Events are stored in a dedicated table
▸ Basing on events, a read model is up...
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
SLICK
▸ We operate on DBIOAction[T]
▸ a description of actions to be done
▸ executio...
User data
Transaction
READ MODEL
MODEL
UPDATE
EVENT
LISTENER
External systems
EVENT
PROCESSOR
REGISTRYREGISTRYREGISTRY
Eve...
EVENT SOURCING LIVE
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
POTENTIAL PROBLEMS
▸ Ordering of concurrent events operating on the same aggregate r...
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
SUMMING UP: FUNCTIONS INVOLVED
▸ Commands: Data => CommandResult[S, F]

that is, DBI...
ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI
LINKS
▸ https://github.com/softwaremill/slick-eventsourcing
▸ README+blog longer tha...
THANK YOU!
Slick eventsourcing
Slick eventsourcing
Slick eventsourcing
Upcoming SlideShare
Loading in …5
×

Slick eventsourcing

3,824 views

Published on

Slides for Scaladays 2016 presentation, "Transactional Event Sourcing using Slick"

Published in: Software
  • Sex in your area is here: ❶❶❶ http://bit.ly/2F4cEJi ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ♥♥♥ http://bit.ly/2F4cEJi ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Slick eventsourcing

  1. 1. TRANSACTIONAL EVENT SOURCING USING SLICK ADAM WARSKI
  2. 2. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI EVENT SOURCING? ▸ All changes in the system are captured as a sequence of events
  3. 3. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI WHY EVENT SOURCING? ▸ IT: Information Technology ▸ do not loose information! ▸ Audit log ▸ Re-create system state
  4. 4. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI ME + AUDIT = HIBERNATE ENVERS
  5. 5. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI ME ▸ coder @ ▸ Lightbend consulting partner ▸ mainly Scala ▸ open-source: MacWire, ElasticMQ, Bootzooka, … ▸ http://www.warski.org / @adamwarski
  6. 6. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI THE GOAL ▸ Get the benefits of Event Sourcing … ▸ … still being able to leverage RDBMS features ▸ transactions ▸ schema ▸ SQL
  7. 7. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI OTHER APPROACHES ▸ Event Store (https://geteventstore.com) ▸ Akka Persistence (http://doc.akka.io/docs/akka/current) ▸ Eventuate (http://eventuate.io) ▸ + more
  8. 8. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI EVENTS ▸ Immutable ▸ Primary source of truth ▸ Past tense
  9. 9. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI EVENTS ▸ Payload: arbitrary json (case class) ▸ Event type (name of class) ▸ Aggregate type & id ▸ Id, timestamp ▸ Transaction id ▸ User id
  10. 10. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI HOW? ▸ Events are stored in a dedicated table ▸ Basing on events, a read model is updated ▸ similar to what a “traditional” CRUD model could be ▸ Consistency: both done in a single transaction
  11. 11. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI SLICK ▸ We operate on DBIOAction[T] ▸ a description of actions to be done ▸ execution deferred later ▸ can be sequenced using flatMap ▸ yes, it’s a Monad
  12. 12. User data Transaction READ MODEL MODEL UPDATE EVENT LISTENER External systems EVENT PROCESSOR REGISTRYREGISTRYREGISTRY Events COMMAND
  13. 13. EVENT SOURCING LIVE
  14. 14. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI POTENTIAL PROBLEMS ▸ Ordering of concurrent events operating on the same aggregate root ▸ DBIOAction “leaks” ▸ Future wrapping
  15. 15. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI SUMMING UP: FUNCTIONS INVOLVED ▸ Commands: Data => CommandResult[S, F]
 that is, DBIOAction[(Either[S, F], List[Event])] ▸ Event listeners: Event => DBIOAction[List[Event]] ▸ Model updates: Event => DBIOAction[Unit]
  16. 16. ADAM WARSKI, SOFTWAREMILL @ADAMWARSKI LINKS ▸ https://github.com/softwaremill/slick-eventsourcing ▸ README+blog longer than code ▸ only a skeleton ▸ probably for customisation ▸ https://github.com/adamw/slick-eventsourcing-pres
  17. 17. THANK YOU!

×