Download - Akka and AngularJS – Reactive Applications in Practice

Transcript
Page 1: Akka and AngularJS – Reactive Applications in Practice

Dr. Roland Kuhn Akka Tech Lead @rolandkuhn

Akka and AngularJS

Reactive Applications in Practice

Page 2: Akka and AngularJS – Reactive Applications in Practice

Reactive  Applications

The Four Reactive Traits

2

http://reactivemanifesto.org/

Page 3: Akka and AngularJS – Reactive Applications in Practice

Akka !

A fully Reactive toolkit on the JVM

Page 4: Akka and AngularJS – Reactive Applications in Practice

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

Page 5: Akka and AngularJS – Reactive Applications in Practice

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

Page 6: Akka and AngularJS – Reactive Applications in Practice

Command Query Responsibility Segregation

6

Client

write-!side

read-!side

Command Reply Query Reply

Events

Page 7: Akka and AngularJS – Reactive Applications in Practice

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

Page 8: Akka and AngularJS – Reactive Applications in Practice

Spray / Akka HTTP !

An Actor-Based Web Toolkit

Page 9: Akka and AngularJS – Reactive Applications in Practice

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

Page 10: Akka and AngularJS – Reactive Applications in Practice

Important Disclaimer

• I know a lot about Akka, but … • I am not a web developer

10

Page 11: Akka and AngularJS – Reactive Applications in Practice

Gabbler: The Write-Side

11

Gabbler Replayer

Journal

RouterLog

Input

POST

201

Page 12: Akka and AngularJS – Reactive Applications in Practice

Gabbler: The Read-Side

12

Gabbler Replayer

Journal

RouterLog

Input

GET

Replay

200

Page 13: Akka and AngularJS – Reactive Applications in Practice

Gabbler: The Whole Thing

13

Gabbler Replayer

Journal

RouterLog

Input

Page 14: Akka and AngularJS – Reactive Applications in Practice

Further Information

• Code at https://github.com/hseeberger/gabbler • currently a pull request

• See also http://akka.io

14

Page 15: Akka and AngularJS – Reactive Applications in Practice

©Typesafe 2014 – All Rights Reserved