Akka in Action
brief contents
contents
preface
acknowledgments
about this book
Intended audience
Roadmap
Code conventions and downloads
Software requirements
Author Online
About the authors
About the cover illustration
1 Introducing Akka
1.1 What is Akka?
1.2 Actors: a quick overview
1.3 Two approaches to scaling: setting up our example
1.4 Traditional scaling
1.4.1 Traditional scaling and durability: move everything to the database
1.4.2 Traditional scaling and interactive use: polling
1.4.3 Traditional scaling and interactive use: polling
1.5 Scaling with Akka
1.5.1 Scaling with Akka and durability: sending and receiving messages
1.5.2 Scaling with Akka and interactive use: push messages
1.5.3 Scaling with Akka and failure: asynchronous decoupling
1.5.4 The Akka approach: sending and receiving messages
1.6 Actors: one programming model to rule up and out
1.6.1 An asynchronous model
1.6.2 Actor operations
1.7 Akka actors
1.7.1 ActorSystem
1.7.2 ActorRef, mailbox, and actor
1.7.3 Dispatchers
1.7.4 Actors and the network
1.8 Summary
2 Up and running
2.1 Clone, build, and test interface
2.1.1 Build with sbt
2.1.2 Fast-forward to the GoTicks.com REST server
2.2 Explore the actors in the app
2.2.1 Structure of the app
2.2.2 The actor that handles the sale: TicketSeller
2.2.3 The BoxOffice actor
2.2.4 RestApi
2.3 Into the cloud
2.3.1 Create the app on Heroku
2.3.2 Deploy and run on Heroku
2.4 Summary
3 Test-driven development with actors
3.1 Testing actors
3.2 One-way messages
3.2.1 SilentActor examples
3.2.2 SendingActor example
3.2.3 SideEffectingActor example
3.3 Two-way messages
3.4 Summary
4 Fault tolerance
4.1 What fault tolerance is (and what it isn’t)
4.1.1 Plain old objects and exceptions
4.1.2 Let it crash
4.2 Actor lifecycle
4.2.1 Start event
4.2.2 Stop event
4.2.3 Restart event
4.2.4 Putting the lifecycle pieces together
4.2.5 Monitoring the lifecycle
4.3 Supervision
4.3.1 Supervisor hierarchy
4.3.2 Predefined strategies
4.3.3 Custom strategies
4.4 Summary
5 Futures
5.1 Use cases for futures
5.2 In the future nobody blocks
5.2.1 Promises are promises
5.3 Futuristic errors
5.4 Combining futures
5.5 Combining futures with actors
5.6 Summary
6 Your first distributed Akka app
6.1 Scaling out
6.1.1 Common network terminology
6.1.2 Reasons for a distributed programming model
6.2 Scaling out with remoting
6.2.1 Making the GoTicks.com app distributed
6.2.2 Remote REPL action
6.2.3 Remote lookup
6.2.4 Remote deployment
6.2.5 Multi-JVM testing
6.3 Summary
7 Configuration, logging, and deployment
7.1 Configuration
7.1.1 Trying out Akka configuration
7.1.2 Using defaults
7.1.3 Akka configuration
7.1.4 Multiple systems
7.2 Logging
7.2.1 Logging in an Akka application
7.2.2 Using logging
7.2.3 Controlling Akka’s logging
7.3 Deploying actor-based applications
7.4 Summary
8 Structural patterns for actors
8.1 Pipes and filters
8.1.1 Enterprise integration pattern: pipes and filters
8.1.2 Pipes and filters in Akka
8.2 Enterprise integration pattern: scatter-gather
8.2.1 Applicability
8.2.2 Parallel tasks with Akka
8.2.3 Implementing the scatter component using the recipient list pattern
8.2.4 Implementing the gather component with the aggregator pattern
8.2.5 Combining the components into the scatter-gather pattern
8.3 Enterprise integration pattern: routing slip
8.4 Summary
9 Routing messages
9.1 The enterprise integration router pattern
9.2 Balance load using Akka routers
9.2.1 Akka pool router
9.2.2 Akka group router
9.2.3 ConsistentHashing router
9.3 Implementing the router pattern using actors
9.3.1 Content-based routing
9.3.2 State-based routing
9.3.3 Router implementations
9.4 Summary
10 Message channels
10.1 Channel types
10.1.1 Point-to-point
10.1.2 Publish-subscribe
10.2 Specialized channels
10.2.1 Dead letter
10.2.2 Guaranteed delivery
10.3 Summary
11 Finite-state machines and agents
11.1 Using a finite-state machine
11.1.1 Quick introduction to finite-state machines
11.1.2 Creating an FSM model
11.2 Implementation of an FSM model
11.2.1 Implementing transitions
11.2.2 Implementing the entry actions
11.2.3 Timers within FSM
11.2.4 Termination of FSM
11.3 Implement shared state using agents
11.3.1 Simple shared state with agents
11.3.2 Waiting for the state update
11.4 Summary
12 System integration
12.1 Message endpoints
12.1.1 Normalizer
12.1.2 Canonical data model
12.2 Implementing endpoints using Apache Camel
12.2.1 Implement a consumer endpoint receiving messages from an external system
12.2.2 Implement a producer endpoint sending messages to an external system
12.3 Implementing an HTTP interface
12.3.1 The HTTP example
12.3.2 Implementing a REST endpoint with akka-http
12.4 Summary
13 Streaming
13.1 Basic stream processing
13.1.1 Copying files with sources and sinks
13.1.2 Materializing runnable graphs
13.1.3 Processing events with flows
13.1.4 Handling errors in streams
13.1.5 Creating a protocol with a BidiFlow
13.2 Streaming HTTP
13.2.1 Receiving a stream over HTTP
13.2.2 Responding with a stream over HTTP
13.2.3 Custom marshallers and unmarshallers for content type and negotiation
13.3 Fan in and fan out with the graph DSL
13.3.1 Broadcasting to flows
13.3.2 Merging flows
13.4 Mediating between producers and consumers
13.4.1 Using buffers
13.5 Rate-detaching parts of a graph
13.5.1 Slow consumer, rolling up events into summaries
13.5.2 Fast consumer, expanding metrics
13.6 Summary
14 Clustering
14.1 Why use clustering?
14.2 Cluster membership
14.2.1 Joining the cluster
14.2.2 Leaving the cluster
14.3 Clustered job processing
14.3.1 Starting the cluster
14.3.2 Work distribution using routers
14.3.3 Resilient jobs
14.3.4 Testing the cluster
14.4 Summary
15 Actor persistence
15.1 Recovering state with event sourcing
15.1.1 Updating records in place
15.1.2 Persisting state without updates
15.1.3 Event sourcing for actors
15.2 Persistent actors
15.2.1 Persistent actor
15.2.2 Testing
15.2.3 Snapshots
15.2.4 Persistence query
15.2.5 Serialization
15.3 Clustered persistence
15.3.1 Cluster singleton
15.3.2 Cluster sharding
15.4 Summary
16 Performance tips
16.1 Performance analysis
16.1.1 System performance
16.1.2 Performance parameters
16.2 Performance measurement of actors
16.2.1 Collect mailbox data
16.2.2 Collecting processing data
16.3 Improving performance by addressing bottlenecks
16.4 Configure dispatcher
16.4.1 Recognizing thread pool problems
16.4.2 Using multiple instances of dispatchers
16.4.3 Changing thread pool size statically
16.4.4 Using a dynamic thread pool size
16.5 Changing thread releasing
16.5.1 Limitations on thread release settings
16.6 Summary
17 Looking ahead
17.1 akka-typed module
17.2 Akka Distributed Data
17.3 Summary
index
Symbols
Numerics
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X