SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
Messaging Patterns with
Akka (Remote) Actors
John Nestor and Dragos Manolescu
Whitepages, Inc.
April 14, 2015
Prelude
• JLine (http://jline.sourceforge.net)
• Command history, tab completion, line editing
• Custom key bindings
• PersistJson (https://github.com/nestorpersist/json)
• Fast Scala JSON parser
• JSON tree/Scala classes
• Pretty/Compact
• Demo code at https://github.com/polymorphic/akka-messaging-
patterns.git
Akka Remote Actors
• Design decisions:
• Symmetric communication
• Symmetric roles
• Remote scenarios:
• Lookup
• Remote creation
Akka Actor Model
Actor
BehaviorMailbox
Parent
Child
Child
M M M
Actor
BehaviorMailbox
Messages
- Configuration
- Thread pools
Actor System
Akka Actor Model w/
Remoting
Actor
BehaviorMailbox
Parent
Child
Child
M M MActor
BehaviorMailbox
Messages
- Configuration
- Thread pools
Actor System
Lookup via ActorSelection
Remote creation via deployment configuration
- Configuration
- Thread pools
Actor System
Actor System Configuration
for Remoting
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "127.0.0.1"
port = 2552
}
}
}
Messaging Pattern:
OneWay
Client Actor
Server Actor
JSON(cmd, id, msg)
(server work)
Messaging Pattern:
Request-Reply
Client Actor
Server Actor
JSON(cmd, id, msg)
(server work)
JSON("done", id, msg)
Messaging Pattern:
Request-Reply with Failure
Client Actor
Server Actor
JSON(cmd, id, msg)
(server work)
JSON("fail", id, msg)
Messaging Pattern:
Request-Reply with Ack
Client Actor
Server Actor
(server work)
JSON("done", id, msg)
JSON(cmd, id, msg)
JSON("ack", id, msg)
Timer
Messaging Pattern:
Request-Reply with Progress
Client Actor
Server Actor
(server work)
JSON("done", id, msg)
JSON(cmd, id, msg)
(server work)
(server work)
(server work)
JSON("progress", id, msg)
JSON("progress", id, msg)
JSON("progress", id, msg)
Messaging Pattern:
Request-Reply with Query
Client Actor
Server Actor
(server work)
JSON(cmd, id, msg)
(user input)
(server work)
JSON("query", id, msg)
JSON
(server work)
JSON("done", id, msg)
Repeat 2x
Messaging Pattern:
Long Polling
Client Actor
Server Actor
(server work)
JSON("StopListen", id, msg)
JSON
JSON("StartListen", id, msg)
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!
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
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
Thank you

Mais conteúdo relacionado

Semelhante a Messaging Patterns with Akka (Remote) Actors

Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011
Raymond Roestenburg
 
Teaching Apache Spark Clusters to Manage Their Workers Elastically: Spark Sum...
Teaching Apache Spark Clusters to Manage Their Workers Elastically: Spark Sum...Teaching Apache Spark Clusters to Manage Their Workers Elastically: Spark Sum...
Teaching Apache Spark Clusters to Manage Their Workers Elastically: Spark Sum...
Spark Summit
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan
 
"Walk in a distributed systems park with Orleans" Евгений Бобров
"Walk in a distributed systems park with Orleans" Евгений Бобров"Walk in a distributed systems park with Orleans" Евгений Бобров
"Walk in a distributed systems park with Orleans" Евгений Бобров
Fwdays
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with Akka
Maciej Matyjas
 
Сергей Моренец. Serialization and performance in Java
Сергей Моренец. Serialization and performance in JavaСергей Моренец. Serialization and performance in Java
Сергей Моренец. Serialization and performance in Java
Volha Banadyseva
 
End-to-end Data Governance with Apache Avro and Atlas
End-to-end Data Governance with Apache Avro and AtlasEnd-to-end Data Governance with Apache Avro and Atlas
End-to-end Data Governance with Apache Avro and Atlas
DataWorks Summit
 

Semelhante a Messaging Patterns with Akka (Remote) Actors (20)

Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011Real world Scala hAkking NLJUG JFall 2011
Real world Scala hAkking NLJUG JFall 2011
 
Embracing the Future
Embracing the FutureEmbracing the Future
Embracing the Future
 
Teaching Apache Spark Clusters to Manage Their Workers Elastically: Spark Sum...
Teaching Apache Spark Clusters to Manage Their Workers Elastically: Spark Sum...Teaching Apache Spark Clusters to Manage Their Workers Elastically: Spark Sum...
Teaching Apache Spark Clusters to Manage Their Workers Elastically: Spark Sum...
 
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
 
Devignition 2011
Devignition 2011Devignition 2011
Devignition 2011
 
Walk In a Distributed Systems Park with Microsoft Orleans
Walk In a Distributed Systems Park with Microsoft OrleansWalk In a Distributed Systems Park with Microsoft Orleans
Walk In a Distributed Systems Park with Microsoft Orleans
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
 
ESNext, service workers, and the future of the web
ESNext, service workers, and the future of the webESNext, service workers, and the future of the web
ESNext, service workers, and the future of the web
 
February 2016 HUG: Running Spark Clusters in Containers with Docker
February 2016 HUG: Running Spark Clusters in Containers with DockerFebruary 2016 HUG: Running Spark Clusters in Containers with Docker
February 2016 HUG: Running Spark Clusters in Containers with Docker
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
 
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
 
"Walk in a distributed systems park with Orleans" Евгений Бобров
"Walk in a distributed systems park with Orleans" Евгений Бобров"Walk in a distributed systems park with Orleans" Евгений Бобров
"Walk in a distributed systems park with Orleans" Евгений Бобров
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
Serialization and performance in Java
Serialization and performance in JavaSerialization and performance in Java
Serialization and performance in Java
 
Stay Out Please
Stay Out PleaseStay Out Please
Stay Out Please
 
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with Akka
 
Сергей Моренец. Serialization and performance in Java
Сергей Моренец. Serialization and performance in JavaСергей Моренец. Serialization and performance in Java
Сергей Моренец. Serialization and performance in Java
 
End-to-end Data Governance with Apache Avro and Atlas
End-to-end Data Governance with Apache Avro and AtlasEnd-to-end Data Governance with Apache Avro and Atlas
End-to-end Data Governance with Apache Avro and Atlas
 

Último

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Último (20)

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 

Messaging Patterns with Akka (Remote) Actors

  • 1. Messaging Patterns with Akka (Remote) Actors John Nestor and Dragos Manolescu Whitepages, Inc. April 14, 2015
  • 2. Prelude • JLine (http://jline.sourceforge.net) • Command history, tab completion, line editing • Custom key bindings • PersistJson (https://github.com/nestorpersist/json) • Fast Scala JSON parser • JSON tree/Scala classes • Pretty/Compact • Demo code at https://github.com/polymorphic/akka-messaging- patterns.git
  • 3. Akka Remote Actors • Design decisions: • Symmetric communication • Symmetric roles • Remote scenarios: • Lookup • Remote creation
  • 4. Akka Actor Model Actor BehaviorMailbox Parent Child Child M M M Actor BehaviorMailbox Messages - Configuration - Thread pools Actor System
  • 5. Akka Actor Model w/ Remoting Actor BehaviorMailbox Parent Child Child M M MActor BehaviorMailbox Messages - Configuration - Thread pools Actor System Lookup via ActorSelection Remote creation via deployment configuration - Configuration - Thread pools Actor System
  • 6. Actor System Configuration for Remoting akka { actor { provider = "akka.remote.RemoteActorRefProvider" } remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp { hostname = "127.0.0.1" port = 2552 } } }
  • 7. Messaging Pattern: OneWay Client Actor Server Actor JSON(cmd, id, msg) (server work)
  • 8. Messaging Pattern: Request-Reply Client Actor Server Actor JSON(cmd, id, msg) (server work) JSON("done", id, msg)
  • 9. Messaging Pattern: Request-Reply with Failure Client Actor Server Actor JSON(cmd, id, msg) (server work) JSON("fail", id, msg)
  • 10. Messaging Pattern: Request-Reply with Ack Client Actor Server Actor (server work) JSON("done", id, msg) JSON(cmd, id, msg) JSON("ack", id, msg) Timer
  • 11. Messaging Pattern: Request-Reply with Progress Client Actor Server Actor (server work) JSON("done", id, msg) JSON(cmd, id, msg) (server work) (server work) (server work) JSON("progress", id, msg) JSON("progress", id, msg) JSON("progress", id, msg)
  • 12. Messaging Pattern: Request-Reply with Query Client Actor Server Actor (server work) JSON(cmd, id, msg) (user input) (server work) JSON("query", id, msg) JSON (server work) JSON("done", id, msg) Repeat 2x
  • 13. Messaging Pattern: Long Polling Client Actor Server Actor (server work) JSON("StopListen", id, msg) JSON JSON("StartListen", id, msg)
  • 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