2014-02-20 | Akka Concurrency (Vienna Scala User Group)

50 %
50 %
Information about 2014-02-20 | Akka Concurrency (Vienna Scala User Group)
Technology

Published on February 20, 2014

Author: dominikgruber

Source: slideshare.net

Description

Book review of "Akka Concurrency" by Derek Wyatt

Talk given at Vienna Scala User Group on Feb. 20, 2014

Dominik Gruber, @the_dom Vienna Scala User Group – Feb. 20, 2014

Akka Concurrency • 521 pages • Written by Derek Wyatt, Foreword by Roland Kuhn • Published in May 2013 • Based on Akka 2.1 • EUR 17,– (Kindle) / EUR 29,95 (Dead Tree) Akka Concurrency Dominik Gruber • @the_dom

Prerequisites • Basic Scala Knowledge • No Akka Knowledge • “Principles of Reactive Programming” Course: Half of the content will be new Akka Concurrency Dominik Gruber • @the_dom

Pros • Big focus on testing • One big, concise example throughout the book • Exhaustive overview Akka Concurrency Dominik Gruber • @the_dom

Cons • Based on Akka 2.1 • No Akka Cluster • No Akka Persistence Akka Concurrency Dominik Gruber • @the_dom

Table of Contents, I • Why Akka?, Concurrency and Parallelism, Actors,… • Akka Testing • Supervision and DeathWatch • Being Stateful • Routing Messages • Dispatchers and Mailboxes Akka Concurrency Dominik Gruber • @the_dom

Table of Contents, II • Futures, Networking, Remote Actors • Sharing Data with Agents • Granular Concurrency with Dataflow • Patterns / Antipatterns • Add-On Modules • Using Akka from Java Akka Concurrency Dominik Gruber • @the_dom

Some Examples Akka Concurrency Dominik Gruber • @the_dom

Being Stateful def expectHello: Receive = { case “Hello” => sender ! “Goodbye” context.become(expectGoodbye) } def expectGoodbye: Receive = { case “Goodbye” => sender ! “Hello” context.become(expectHello) } def receive = expectHello Akka Concurrency Dominik Gruber • @the_dom

FSM sealed trait State case object Idle extends State case object Active extends State ! sealed trait Data case object Uninitialized extends Data case class Todo(target: ActorRef, queue: immutable.Seq[Any]) extends Data Akka Concurrency Dominik Gruber • @the_dom

class Buncher extends Actor with FSM[State, Data] { startWith(Idle, Uninitialized) when(Idle) { case Event(SetTarget(ref), Uninitialized) => stay using Todo(ref, Vector.empty) } when(Active, stateTimeout = 1 second) { case Event(Flush | StateTimeout, t: Todo) => goto(Idle) using t.copy(queue = Vector.empty) } // … } Akka Concurrency Dominik Gruber • @the_dom

class Buncher extends Actor with FSM[State, Data] { //… onTransition { case Active -> Idle => stateData match { case Todo(ref, queue) => ref ! Batch(queue) } } whenUnhandled { // common code for both states case Event(Queue(obj), t @ Todo(_, v)) => goto(Active) using t.copy(queue = v :+ obj) case Event(e, s) => log.warning("received unhandled request {} in state {}/{}", e, stateName, s) stay } } Akka Concurrency Dominik Gruber • @the_dom

Routers • RoundRobinRouter • RandomRouter • BroadcastRouter • SmallestMailboxRouter • ScatterGatherFirstCompletedRouter Akka Concurrency Dominik Gruber • @the_dom

Dataflow Concurrency def calculatePiTo(places: Int): Future[BigDecimal] = ??? def fibonaccis(n: Int): Future[Seq[BigDecimal]] = ??? val perfect = flow { val pie = calculatePiTo(3000000) val fibs = fibonaccis(31402) val lastFibs = fibs().last pie() * lastFibs * lastFibs } Akka Concurrency Dominik Gruber • @the_dom

Akka Concurrency Dominik Gruber • @the_dom

Future val result = for { i <- Future(5) j <- Future(11) Blocking! } yield j Akka Concurrency Dominik Gruber • @the_dom

Future Translates to: val result = fiveFuture.flatMap { i => Future(11) map { j => j } } Akka Concurrency Dominik Gruber • @the_dom

Future val fiveFuture = Future(5) val elevenFuture = Future(11) val result = for { i <- fiveFuture Non-Blocking j <- elevenFuture } yield j Akka Concurrency Dominik Gruber • @the_dom

Future Translates to: val result = fiveFuture.flatMap { i => elevenFuture map { j => j } } Akka Concurrency Dominik Gruber • @the_dom

Add a comment

Related presentations

Related pages

Google

Поиск информации в интернете: веб страницы, картинки, видео и многое другое.
Read more

TV Programm - Fernsehprogramm - rtv Programmzeitschrift ...

©2015 rtv media group GmbH 10.61.5.112 ...
Read more

NAVER

Hier sollte eine Beschreibung angezeigt werden, diese Seite lässt dies jedoch nicht zu.
Read more

Zentrum für Psychiatrie Emmendingen

Es stehen unseren Patienten, Bewohnern und Besuchern vielfältige Angebote zur Verfügung. Gestalten Sie sich Ihren Aufenthalt oder Ihren Besuch so ...
Read more

CLINOTEL-Krankenhausverbund | Clinotel, Krankenhaus ...

Clinotel ist ein offener Verbund für wirtschaftlich gesunde und innovative Krankenhäuser in öffentlicher und freigemeinnütziger Trä gerschaft. Tr ...
Read more

Funkwerk AG - Intelligent Communication Technology

Mit der Erfahrung aus zahlreichen Projekten bietet Funkwerk integrale Sicherheitskonzepte zur lückenlosen Absicherung von Justizvollzugsanstalten oder ...
Read more

Verbraucherzentrale Energieberatung :: Homepage

Was Sie schon immer über Ihren Kessel wissen wollten, sagt Ihnen der Heiz-Check der Energieberatung der Verbraucherzentrale. Unser Energieberater ...
Read more

Google

Account Options. Sign in; Search settings; Web History
Read more

Washington Post: Breaking News, World, US, DC News ...

Get breaking news alerts from The Washington Post . ... Kurdish militant group claims responsibility for Istanbul bombings that killed 38.
Read more

Feldbergbahn – Machen Sie Ferien am Feldberg

Gute Aussichten! Mit dem Aufzug erreicht man ganz bequem die Aussichtsplattform im 11. Stock des Turms in 45 Meter Höhe. Von dort oben hat man bei gutem ...
Read more