This document discusses messaging patterns with Akka remote actors. It introduces Akka remote actors and how they allow for symmetric communication between actors located remotely. It then covers several common messaging patterns that can be implemented with Akka remote actors like one-way, request-reply, and long polling. It also compares remote actors to HTTP for remote communication and interaction patterns. Sample code is provided on GitHub and additional resources on Akka remoting and effective patterns are referenced.
5. Akka Actor Model w/
Remoting
Actor
BehaviorMailbox
Parent
Child
Child
M M MActor
BehaviorMailbox
Messages
- Con鍖guration
- Thread pools
Actor System
Lookup via ActorSelection
Remote creation via deployment con鍖guration
- Con鍖guration
- Thread pools
Actor System
6. Actor System Con鍖guration
for Remoting
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "127.0.0.1"
port = 2552
}
}
}
14. Messaging Patterns
More patterns:
Sender retries on timeout or failure
A -> B, B -> C, C responds to A directly
Routers
Suggestions for more patterns welcome!
15. Summary:
Remote Actors or HTTP?
Remote actors:
Symmetric; uniform for local/remote
Rich interaction patterns, very simple protocol
Problems with NAT and load balancers
HTTP:
Asymmetric; remote-only
Simple interaction patterns, complex protocol
Ubiquitous
Originally designed for a very different purpose
16. For More Information
Sample code: https://github.com/polymorphic/akka-
messaging-patterns.git
Akka remoting: http://doc.akka.io/docs/akka/2.3.9/
scala/remoting.html
JLine http://jline.sourceforge.net
PersistJson https://github.com/nestorpersist/json
Effective Akka, Patterns and Best Practices by Jamie
Allen