SlideShare a Scribd company logo
Akka and AngularJS 
Reactive Applications in Practice 
Dr. Roland Kuhn 
Akka Tech Lead 
@rolandkuhn
The Four Reactive Traits 
Reactive 
Applications 
2 
http://reactivemanifesto.org/
Akka 
! 
A fully Reactive toolkit on the JVM
The Actor Model 
• fully message-driven: an Actor can react by 
• sending messages to other Actors 
• creating Actors 
• denominating behavior for the next message 
• Actors are effectively single-threaded 
• failures are contained and escalated within the 
supervisor hierarchy 
• scaling up & out through location transparency 
4
Persistence Model: Event Sourcing 
• based on storing change instead of updating state 
• persistent Actors generate events: 
• historic facts that do not change thereafter 
• storage is append-only log 
• current Actor state is updated by consuming events 
• Actor can revisit the past by replaying events 
• events contain more business information than 
current state snapshot 
5
Command Query Responsibility Segregation 
6 
Events 
Client 
write-! 
side 
read-! 
side 
Command Reply Query Reply
Command Query Responsibility Segregation 
• persistent Actors on write-side generate events 
• read-side independently consumes event streams 
• read model is fully decoupled from write model 
• queries are served from optimal storage: 
• SQL store 
• graph database 
• in-memory live view 
• new read model can be generated on demand 
7
Spray / Akka HTTP 
! 
An Actor-Based Web Toolkit
Web-Server made Simple 
• HTTP requests and responses are Actor messages 
• powerful routing DSL turns Actor into Web-Server 
• not a web framework: 
• just expose Actors as web endpoints 
• nicely suited for RESTful APIs 
9
Important Disclaimer 
• I know a lot about Akka, but … 
• I am not a web developer 
10
Gabbler: The Write-Side 
11 
Log Router 
Gabbler Replayer 
Journal 
Input 
POST 
201
Gabbler: The Read-Side 
12 
Log Router 
Gabbler Replayer 
Journal 
Input 
GET 
Replay 
200
Gabbler: The Whole Thing 
13 
Log Router 
Gabbler Replayer 
Journal 
Input
Further Information 
• Code at https://github.com/hseeberger/gabbler 
• currently a pull request 
• See also http://akka.io 
14
©Typesafe 2014 – All Rights Reserved

More Related Content

Akka and AngularJS – Reactive Applications in Practice

  • 1. Akka and AngularJS Reactive Applications in Practice Dr. Roland Kuhn Akka Tech Lead @rolandkuhn
  • 2. The Four Reactive Traits Reactive Applications 2 http://reactivemanifesto.org/
  • 3. Akka ! A fully Reactive toolkit on the JVM
  • 4. The Actor Model • fully message-driven: an Actor can react by • sending messages to other Actors • creating Actors • denominating behavior for the next message • Actors are effectively single-threaded • failures are contained and escalated within the supervisor hierarchy • scaling up & out through location transparency 4
  • 5. Persistence Model: Event Sourcing • based on storing change instead of updating state • persistent Actors generate events: • historic facts that do not change thereafter • storage is append-only log • current Actor state is updated by consuming events • Actor can revisit the past by replaying events • events contain more business information than current state snapshot 5
  • 6. Command Query Responsibility Segregation 6 Events Client write-! side read-! side Command Reply Query Reply
  • 7. Command Query Responsibility Segregation • persistent Actors on write-side generate events • read-side independently consumes event streams • read model is fully decoupled from write model • queries are served from optimal storage: • SQL store • graph database • in-memory live view • new read model can be generated on demand 7
  • 8. Spray / Akka HTTP ! An Actor-Based Web Toolkit
  • 9. Web-Server made Simple • HTTP requests and responses are Actor messages • powerful routing DSL turns Actor into Web-Server • not a web framework: • just expose Actors as web endpoints • nicely suited for RESTful APIs 9
  • 10. Important Disclaimer • I know a lot about Akka, but … • I am not a web developer 10
  • 11. Gabbler: The Write-Side 11 Log Router Gabbler Replayer Journal Input POST 201
  • 12. Gabbler: The Read-Side 12 Log Router Gabbler Replayer Journal Input GET Replay 200
  • 13. Gabbler: The Whole Thing 13 Log Router Gabbler Replayer Journal Input
  • 14. Further Information • Code at https://github.com/hseeberger/gabbler • currently a pull request • See also http://akka.io 14
  • 15. ©Typesafe 2014 – All Rights Reserved