The document summarizes a presentation about the book "Akka Concurrency" by Derek Wyatt. It provides an overview of the book's content including chapters on actors, testing, routing messages, dataflow concurrency and examples of stateful actors and using the finite state machine pattern. It also notes that while the book provides an exhaustive overview of Akka, it is based on an older version of Akka and does not cover newer features like clustering and persistence.
4. 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
5. 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
6. Pros
•
Big focus on testing
•
One big, concise example throughout the book
•
Exhaustive overview
Akka Concurrency
Dominik Gruber • @the_dom
7. Cons
•
Based on Akka 2.1
•
No Akka Cluster
•
No Akka Persistence
Akka Concurrency
Dominik Gruber • @the_dom
8. 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
9. 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
12. 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
13. 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
14. 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