Above the Clouds: Introducing Akka - GOTO...
Transcript of Above the Clouds: Introducing Akka - GOTO...
![Page 1: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/1.jpg)
Above the Clouds:Introducing Akka
Fredrik EkholdtTypesafe
Email: [email protected] : @ekhfre
Wednesday, November 23, 11
![Page 2: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/2.jpg)
The problem
It is way too hard to build:1. correct highly concurrent systems
2. truly scalable systems
3. fault-tolerant systems that self-heals
...using “state-of-the-art” tools
Wednesday, November 23, 11
![Page 3: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/3.jpg)
Introducing
Wednesday, November 23, 11
![Page 4: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/4.jpg)
Introducing
Akka (Áhkká):
The name comes from the goddess in the Sami mythology that represented all the wisdom and
beauty in the world.
It is also the name of a beautiful mountain in Laponia in the north part of Sweden
Wednesday, November 23, 11
![Page 5: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/5.jpg)
Introducing
View from the summit
Wednesday, November 23, 11
![Page 6: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/6.jpg)
Vision
Simpler
Concurrency
Scalability
Fault-tolerance
Wednesday, November 23, 11
![Page 7: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/7.jpg)
CORE SERVICES
THE TOOLBOX...
Wednesday, November 23, 11
![Page 8: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/8.jpg)
The Actor...
Wednesday, November 23, 11
![Page 9: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/9.jpg)
Behavior
State
Actor
Wednesday, November 23, 11
![Page 10: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/10.jpg)
Event-driven
Behavior
State
Actor
Wednesday, November 23, 11
![Page 11: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/11.jpg)
Event-driven
Behavior
State
Actor
Wednesday, November 23, 11
![Page 12: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/12.jpg)
Event-driven
Behavior
State
Actor
Wednesday, November 23, 11
![Page 13: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/13.jpg)
Event-driven
Behavior
State
Actor
Wednesday, November 23, 11
![Page 14: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/14.jpg)
Event-driven
Behavior
State
Actor
Wednesday, November 23, 11
![Page 15: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/15.jpg)
Behavior
State
Actor
Wednesday, November 23, 11
![Page 16: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/16.jpg)
Event-driven
Behavior
State
Actor
Wednesday, November 23, 11
![Page 17: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/17.jpg)
Akka ActorsLet the hakking begin!
Text
Wednesday, November 23, 11
![Page 18: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/18.jpg)
•Create an Actor: class AnActor extends Actor•Start an Actor: actorOf[AnActor].start()•Safe
•Encapsulated state•One message at a time
•Asynchronous:•bang (!)
•Reply: •self.reply ( m )•actor ? “message”
Take aways
Wednesday, November 23, 11
![Page 19: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/19.jpg)
Akka Futureswithout blocking
using
Wednesday, November 23, 11
![Page 20: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/20.jpg)
FuturePromise
Future with value
Wednesday, November 23, 11
![Page 21: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/21.jpg)
FuturePromise
Future with value
Wednesday, November 23, 11
![Page 22: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/22.jpg)
FuturePromise
Future with value
Wednesday, November 23, 11
![Page 23: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/23.jpg)
•Use Futures when you need something in the Future without blocking
•Use onComplete•Compose Futures
•for - comprehensions•Check out the Futures utilities (firstCompletedOf
and much, much more)
Take aways
Wednesday, November 23, 11
![Page 24: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/24.jpg)
Remote ActorsAnother snippet of code...
Wednesday, November 23, 11
![Page 25: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/25.jpg)
New Remote Actors
Wednesday, November 23, 11
![Page 26: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/26.jpg)
appContext.actorOf[MyActor](“my-service”)
Name
Bind the actor to a name
Wednesday, November 23, 11
![Page 27: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/27.jpg)
•Actor name is virtual and decoupled from how it is deployed
•If no deployment configuration exists then actor is deployed as local
•The same system can be configured as distributed without code change (even change at runtime)
•Write as local but deploy as distributed in the cloud without code change
•Allows runtime to dynamically and adaptively change topology
Deployment
Wednesday, November 23, 11
![Page 28: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/28.jpg)
akka { actor { deployment { /path/to/my-service { router = "round-robin" nr-of-instances = 3 remote {
nodes = ["wallace:2552", "gromit:2552"] } } } }}
Deployment configuration
Wednesday, November 23, 11
![Page 29: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/29.jpg)
•Decentralized P2P gossip-based cluster membership (dynamo-style w/ vector clocks, hand-off on fail-over etc.)
•Automatic adaptive cluster rebalancing•Automatic cluster-wide deployment•Highly available configuration service•Automatic replication with automatic fail-over upon
node crash•Transparent and user-configurable load-balancing•...and much more
The runtime provides
Wednesday, November 23, 11
![Page 30: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/30.jpg)
Akka Node
Wednesday, November 23, 11
![Page 31: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/31.jpg)
Akka Nodeval ping = actorOf[Ping](“ping”)val pong = actorOf[Pong](“pong”)
pong ! Ball(ping)
Wednesday, November 23, 11
![Page 32: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/32.jpg)
Akka Nodeval ping = actorOf[Ping](“ping”)val pong = actorOf[Pong](“pong”)
pong ! Ball(ping)
Ping Pong
Wednesday, November 23, 11
![Page 33: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/33.jpg)
Akka Node
AkkaCluster Node
Ping Pong
Wednesday, November 23, 11
![Page 34: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/34.jpg)
Akka Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
Ping Pong
Wednesday, November 23, 11
![Page 35: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/35.jpg)
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
Ping Pong
Wednesday, November 23, 11
![Page 36: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/36.jpg)
akka { actor { deployment { /ping {} /pong { router = "round-robin" nr-of-instances = 3 } } }}
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
Ping Pong
Wednesday, November 23, 11
![Page 37: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/37.jpg)
akka { actor { deployment { /ping {} /pong { router = "round-robin" nr-of-instances = 3 } } }}
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
Ping
Pong
Wednesday, November 23, 11
![Page 38: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/38.jpg)
akka { actor { deployment { /ping {} /pong { router = "round-robin" nr-of-instances = 3 } } }}
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
AkkaCluster Node
Ping
Pong
Pong
PongWednesday, November 23, 11
![Page 39: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/39.jpg)
Summingup
Wednesday, November 23, 11
![Page 40: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/40.jpg)
Let it crash fault-tolerance
Wednesday, November 23, 11
![Page 41: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/41.jpg)
...let’s take a standard OO application
Wednesday, November 23, 11
![Page 42: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/42.jpg)
Wednesday, November 23, 11
![Page 43: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/43.jpg)
Which components have critically important state
and explicit error handling?
Wednesday, November 23, 11
![Page 44: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/44.jpg)
Wednesday, November 23, 11
![Page 45: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/45.jpg)
Fault-tolerant onion-layered Error Kernel
Wednesday, November 23, 11
![Page 46: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/46.jpg)
ErrorKernel
Wednesday, November 23, 11
![Page 47: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/47.jpg)
ErrorKernel
Wednesday, November 23, 11
![Page 48: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/48.jpg)
ErrorKernel
Wednesday, November 23, 11
![Page 49: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/49.jpg)
ErrorKernel
Wednesday, November 23, 11
![Page 50: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/50.jpg)
ErrorKernel
Wednesday, November 23, 11
![Page 51: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/51.jpg)
ErrorKernel
Wednesday, November 23, 11
![Page 52: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/52.jpg)
Node 1 Node 2
Wednesday, November 23, 11
![Page 53: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/53.jpg)
// from within an actorcontext.actorOf[MyActor]
transparent and automatic fault handling by design
Parental automatic supervision
Wednesday, November 23, 11
![Page 54: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/54.jpg)
A
B
BarFoo
C
BE
A
D
C
Guardian Actor
Parental automatic supervision
Wednesday, November 23, 11
![Page 55: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/55.jpg)
A
B
BarFoo
C
BE
A
D
C
Guardian Actor
/Foo
Parental automatic supervision
Wednesday, November 23, 11
![Page 56: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/56.jpg)
A
B
BarFoo
C
BE
A
D
C
Guardian Actor
/Foo
/Foo/A
Parental automatic supervision
Wednesday, November 23, 11
![Page 57: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/57.jpg)
A
B
BarFoo
C
BE
A
D
C
Guardian Actor
/Foo
/Foo/A
/Foo/A/B
Parental automatic supervision
Wednesday, November 23, 11
![Page 58: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/58.jpg)
Supervisionclass MySupervisor extends Actor { faultHandler = OneForOneStrategy({ case _: ActorKilledException => Stop case _: ArithmeticException => Resume case _: Exception => Restart case _ => Escalate
}, maxNrOfRetries = None, withinTimeRange = None)
def receive = { case NewUser(name) => ... = context.actorOf[User](name) }}
Wednesday, November 23, 11
![Page 59: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/59.jpg)
Supervisionclass MySupervisor extends Actor { faultHandler = OneForOneStrategy({ case _: ActorKilledException => Stop case _: ArithmeticException => Resume case _: Exception => Restart case _ => Escalate
}, maxNrOfRetries = None, withinTimeRange = None)
def receive = { case NewUser(name) => ... = context.actorOf[User](name) }}
AllForOneStrategy
Wednesday, November 23, 11
![Page 60: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/60.jpg)
class FaultTolerantService extends Actor { ... override def preRestart( reason: Throwable, message: Option[Any]) = { ... // clean up before restart } override def postRestart(reason: Throwable) = { ... // init after restart }}
Manage failure
Wednesday, November 23, 11
![Page 61: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/61.jpg)
ARCHITECTURE
TYPESAFE STACK
ADD-ONS
Wednesday, November 23, 11
![Page 62: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/62.jpg)
Get it and learn morehttp://akka.io
http://typesafe.com
https://gist.github.com/1388237
Wednesday, November 23, 11
![Page 63: Above the Clouds: Introducing Akka - GOTO Conferencegotocon.com/dl/goto-prague-2011/slides/FredrikEkholdt... · 2011-11-23 · Introducing Akka (çhkk ): The name comes from the goddess](https://reader034.fdocuments.net/reader034/viewer/2022042408/5f230760bca18702c6260b88/html5/thumbnails/63.jpg)
EOFWednesday, November 23, 11