SlideShare a Scribd company logo
1 of 45
CREATING SCALABLE MESSAGE-
DRIVEN SOLUTIONS
(WITH AKKA.NET)
David Hoerster
ABOUT ME
5-Time .NET (Visual C#) MVP (April 2011)
Sr. Solutions Architect at Confluence
One of the organizers for Pittsburgh TechFest (http://pghtechfest.com)
Organizer of Pittsburgh Reactive Dev Group (http://meetup.com/reactive)
Past President of Pittsburgh .NET Users Group
Twitter - @DavidHoerster
Blog – http://blog.agileways.com
Email – david@agileways.com
AGENDA
Messages as Part of Application Design
Being Reactive
What the Actor Model Provides
Hello Akka.NET
Working with Akka.NET
Cross-Process Actor Systems (Akka.Remote)
CQRS
Command Query Responsibility Segregation
 Coined by Greg Young
Evolution of CQS (Command Query Separation)
 Coined by Bertrand Meyer
Both revolve around the separation of writes (command) and reads
(query)
CQS is more at the unit level
CQRS is at the bounded context level, or so
MESSAGES
The core of CQRS  Messages
Communication from the service layer to the domain via commands
 Command handlers could also update the underlying repository
As actions happen, events are raised
Event handlers could issue other commands
Event handlers could update the underlying repository
MESSAGES
Regardless of how it’s implemented, communication between
application parts is via messages
Not only helps communicate intent of the action
 “PublishWidget”, “ExpireWorkItem”, “UpdateDefinition”, “DefinitionUpdated”
But allows for remote handling of messages
 Queue, REST payload, etc.
MESSAGES ARE KEY TO BEING
REACTIVE
SO?
So how does this affect my system design?
Let’s consider some procedural pitfalls
WORD COUNTER EXAMPLE
Simple program to count the occurrences of words in a document
Print out the top 25 words and their counts at the end
Can be accomplished easily via procedural code
WORD COUNTER EXAMPLE
WORD COUNTER EXAMPLE
What if you wanted to spread out the counting load?
What if you wanted to scale out to other nodes/processes/machines?
Fault tolerance, concurrent actions, etc.?
BUILDING CONCURRENT APPS
In word counter, may need to spawn some threads
Lock some critical sections, etc.
The system becomes responsible for knowing everything going on
 Very Proactive (not Reactive!) system
SIDE NOTE: REACTIVE VS.
PROACTIVE
Isn’t proactive a good thing?
A system taking upon itself to
check state is proactive
 It’s doing too much
A reactive system reacts to
events that occur
 It’s doing just the right amount
SIDE NOTE: REACTIVE VS.
PROACTIVE
Isn’t proactive a good thing?
A system taking upon itself to
check state is proactive
 It’s doing too much
A reactive system reacts to
events that occur
 It’s doing just the right amount
System
EvtEvt
System
EvtEvt
Proactive
Reactive
REAL WORLD SCENARIO
Loosely structured data
Multiple files to combine
Operations to perform during the projection process
REAL WORLD SCENARIO
File File File
Join
Op
Join/
End
REAL WORLD SCENARIO
Number of “steps”
May need some sub-steps
Can be broken down into individual pieces
 Actors
Communicate via messages for loose coupling
REAL WORLD SCENARIO
Actually looks like this:
Multiple sources
Several transforms
Several joins
Configurable
ACTOR MODEL
Actor Model is a system made of small units of concurrent
computation
 Formulated in the early 70’s
Each unit is an actor
Communicates to each other via messages
Actors can have children, which they can supervise
WHAT IS AN ACTOR?
Class that encapsulates state and behavior
 State can be persisted (Akka.Persistence)
 Behavior can be switched (Become/Unbecome)
Has a mailbox to receive messages
 Ordered delivery by default
 Queue
Can create child actors
Has a supervisory strategy for child actors
 How to handle misbehaving children
Are always thread safe
Have a lifecycle
 Started, stopped, restarted
AKKA.NET
Akka.NET is an open source framework
Actor Model for .NET
Port of Akka (for JVM/Scala)
http://getakka.net
NuGet package – search for Akka.Net (not the first result usually!)
STARTING WITH AKKA.NET
Akka.NET is a hierarchical system
Root of the system is ActorSystem
Expensive to instantiate – create and hold!
ActorSystem can then be used to create Actors
CREATING AN ACTOR
An Actor has a unique address
Can be accessed/communicated to like a URI
Call ActorOf off ActorSystem, provide it a name
 URI (actor path) is created hierarchically
Actor Path = akka://myName/user/announcer
SENDING A MESSAGE
Messages are basis of actor communication
 Should be IMMUTABLE!!!
“Tell” an actor a message
Async call
 Immutable!!
RECEIVING A MESSAGE
Create your Actor
Derive from ReceiveActor
In constructor, register your
message subscriptions
RECEIVING A MESSAGE
Each actor has a mailbox
Messages are received in the actor’s mailbox (queue)
Actor is notified that there’s a message
 It receives the message
 Takes it out of the mailbox
 Next one is queued up
Ordered delivery by default
 Other mailboxes (like Priority) that are out-of-order
Actor
Mailbox
Msg
HELLO AKKA.NET Demo
CREATING CHILDREN
Best to call ActorOf to get an IActorRef
Create a static Props creator
Actor path is relative to parent’s actor path
 akka://myDemo/user/countChocula/{childName}
When creating a child, good idea to name it
 So you can reference it later!
WORD COUNTER WITH ACTORS
Program sends StartCount message to CountSupervisor
CountSupervisor, for each line, sends line to one of 5 LineCounterActors
(ReadLineForCounting message)
LineCounterActor counts the word in that line
Tells the Sender (CountSupervisor) the results (MappedList message)
CountSupervisor aggregates results of MappedList messages
When all lines complete, CountSupervisor sends each LineActor a Complete
message
LineCounterActor cleans up and sends CountSupervisor Complete
When all LineCounterActors are Complete, CountSupervisor prints out top 25
words
MAP-REDUCE DEMO
ROUTING
Map Reduce example used Round Robin
There are others OOTB
 Broadcast
 Random
 Consistent Hashing (used by Cluster)
 Smallest Mailbox
 More
Pools and Groups
 Pools are more anonymous
 Groups are pre-created
FINDING CHILDREN
Within an actor, call Context.Child with the name of the child actor
If not found, ActorRefs.Nobody is returned
If found, you have an IActorRef to work with
Using ActorSelection doesn’t guarantee actor is initialized
MORE COMPLEX ACTOR DEMO
baseball
gameCoo
rdinator
gameInfo
-x
gameInfo
-y
playerSup
ervisor
batter-abatter-bbatter-c
c-01 c-11 c-32
INTEGRATION
Integration with other systems is simple
Best to encapsulate in its own actor
Contain any errors there
 Prevent affecting parts of the system further upstream
ASYNC
Actors have messages delivered to them in order via a Mailbox
As message is received, handed to Actor to process
Messages in mailbox queue up
As a result, async processing of messages isn’t possible
 Receive<> (async msg => { … }) doesn’t work
If you need to perform async tasks within Receive
 PipeTo(Self) usually does the trick
 Re-queues message back on Mailbox
 When delivered, actor resumes
Actor
Mailbox
Msg
PipeTo
ACTORS ACROSS PROCESSES
Akka.Remote module
Configure via HOCON
 Human Optimized Configuration Object Notation
Allows an actor system to distribute messages to actors across
processes
Location transparency!!
ACTORS ACROSS PROCESSES
baseball
gameCoor
dinator
gameInfo
-x
gameInfo
-y
playerSup
ervisor
batter-abatter-bbatter-c
eventSupe
rvisor
batter-a batter-b
c-01 c-11 c-32
atBatWrite
r
ACTORS ACROSS PROCESSES
Actor Path modified
 akka.tcp://localhost:50000@{system}/user/{supervisor}/{name}
Protocol and location added to actor path
Protocol defaults to tcp, but you can provide your own
Actor path above is remote path
AKKA.REMOTE DEMO
ELASTICITY WITH ACTORS
Akka.Cluster
Multiple nodes of an actor system acting as one
Allows for failure
Can also expand out for performance
SAVING ACTOR STATE
Akka.Persistence
Persist each message (or snapshots) to storage
Like event sourcing
Rehydrate actor state after failure or for whatever reason
ASKING AN ACTOR
Wait for a response from an actor
Somewhat of an anti-pattern for Actor Model
If used, use sparingly
HANDLING ERRORS
An exception during processing with a classic app could crash the
whole system
An exception within a child actor is isolated
IS AKKA.NET…?
Pub/Sub?
 No, but it could be
Message Bus, like RabbitMQ or MassTransit
 Uses messages to communicate
 Message bus concerned with building a distributed system topology
Storm, ETL/ELT, etc.?
 Kind of
 Can build system like that with Akka.NET
RESOURCES
http://getakka.net
Petabridge blog
https://petabridge.com/blog/
Gitter
https://gitter.im/akkadotnet/akka.net
https://gitter.im/petabridge/akka-bootcamp

More Related Content

What's hot

Distributed Deep Learning with Docker at Salesforce
Distributed Deep Learning with Docker at SalesforceDistributed Deep Learning with Docker at Salesforce
Distributed Deep Learning with Docker at SalesforceDocker, Inc.
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelMassimo Bonanni
 
I Am MongoDB – And So Can You!
I Am MongoDB – And So Can You!I Am MongoDB – And So Can You!
I Am MongoDB – And So Can You!MongoDB
 
Building and running Spring Cloud-based microservices on AWS ECS
Building and running Spring Cloud-based microservices on AWS ECSBuilding and running Spring Cloud-based microservices on AWS ECS
Building and running Spring Cloud-based microservices on AWS ECSJoris Kuipers
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaNexThoughts Technologies
 
Building A CICD Pipeline for Deploying to Containers
Building A CICD Pipeline for Deploying to ContainersBuilding A CICD Pipeline for Deploying to Containers
Building A CICD Pipeline for Deploying to ContainersAmazon Web Services
 
Introduction to Akka.NET and Akka.Cluster
Introduction to Akka.NET and Akka.ClusterIntroduction to Akka.NET and Akka.Cluster
Introduction to Akka.NET and Akka.Clusterpetabridge
 
Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Massimo Bonanni
 
Serverless in production, an experience report (NDC London 2018)
Serverless in production, an experience report (NDC London 2018)Serverless in production, an experience report (NDC London 2018)
Serverless in production, an experience report (NDC London 2018)Yan Cui
 
Intro to elixir and phoenix
Intro to elixir and phoenixIntro to elixir and phoenix
Intro to elixir and phoenixJared Smith
 
Durable Functions vs Logic App : la guerra dei workflow!!
Durable Functions vs Logic App : la guerra dei workflow!!Durable Functions vs Logic App : la guerra dei workflow!!
Durable Functions vs Logic App : la guerra dei workflow!!Massimo Bonanni
 
MongoDB .local Houston 2019: REST-less Mobile Apps: Why Offline-first and Syn...
MongoDB .local Houston 2019: REST-less Mobile Apps: Why Offline-first and Syn...MongoDB .local Houston 2019: REST-less Mobile Apps: Why Offline-first and Syn...
MongoDB .local Houston 2019: REST-less Mobile Apps: Why Offline-first and Syn...MongoDB
 
Deployment - Done Right!
Deployment - Done Right!Deployment - Done Right!
Deployment - Done Right!Eberhard Wolff
 
Microservices pros and cons - houston tech fest
Microservices pros and cons - houston tech festMicroservices pros and cons - houston tech fest
Microservices pros and cons - houston tech festAndrew Siemer
 
Serverless in production, an experience report (London js community)
Serverless in production, an experience report (London js community)Serverless in production, an experience report (London js community)
Serverless in production, an experience report (London js community)Yan Cui
 
Building a CI/CD Pipeline for Containers - DevDay Los Angeles 2017
Building a CI/CD Pipeline for Containers - DevDay Los Angeles 2017Building a CI/CD Pipeline for Containers - DevDay Los Angeles 2017
Building a CI/CD Pipeline for Containers - DevDay Los Angeles 2017Amazon Web Services
 
There is No Server: Immutable Infrastructure and Serverless Architecture
There is No Server: Immutable Infrastructure and Serverless ArchitectureThere is No Server: Immutable Infrastructure and Serverless Architecture
There is No Server: Immutable Infrastructure and Serverless ArchitectureSonatype
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure FunctionsMassimo Bonanni
 
(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy
(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy
(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeployAmazon Web Services
 

What's hot (20)

Distributed Deep Learning with Docker at Salesforce
Distributed Deep Learning with Docker at SalesforceDistributed Deep Learning with Docker at Salesforce
Distributed Deep Learning with Docker at Salesforce
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor model
 
I Am MongoDB – And So Can You!
I Am MongoDB – And So Can You!I Am MongoDB – And So Can You!
I Am MongoDB – And So Can You!
 
Building and running Spring Cloud-based microservices on AWS ECS
Building and running Spring Cloud-based microservices on AWS ECSBuilding and running Spring Cloud-based microservices on AWS ECS
Building and running Spring Cloud-based microservices on AWS ECS
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
Building A CICD Pipeline for Deploying to Containers
Building A CICD Pipeline for Deploying to ContainersBuilding A CICD Pipeline for Deploying to Containers
Building A CICD Pipeline for Deploying to Containers
 
Introduction to Akka.NET and Akka.Cluster
Introduction to Akka.NET and Akka.ClusterIntroduction to Akka.NET and Akka.Cluster
Introduction to Akka.NET and Akka.Cluster
 
Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!
 
Serverless in production, an experience report (NDC London 2018)
Serverless in production, an experience report (NDC London 2018)Serverless in production, an experience report (NDC London 2018)
Serverless in production, an experience report (NDC London 2018)
 
Intro to elixir and phoenix
Intro to elixir and phoenixIntro to elixir and phoenix
Intro to elixir and phoenix
 
Durable Functions vs Logic App : la guerra dei workflow!!
Durable Functions vs Logic App : la guerra dei workflow!!Durable Functions vs Logic App : la guerra dei workflow!!
Durable Functions vs Logic App : la guerra dei workflow!!
 
MongoDB .local Houston 2019: REST-less Mobile Apps: Why Offline-first and Syn...
MongoDB .local Houston 2019: REST-less Mobile Apps: Why Offline-first and Syn...MongoDB .local Houston 2019: REST-less Mobile Apps: Why Offline-first and Syn...
MongoDB .local Houston 2019: REST-less Mobile Apps: Why Offline-first and Syn...
 
Deployment - Done Right!
Deployment - Done Right!Deployment - Done Right!
Deployment - Done Right!
 
What is Docker?
What is Docker?What is Docker?
What is Docker?
 
Microservices pros and cons - houston tech fest
Microservices pros and cons - houston tech festMicroservices pros and cons - houston tech fest
Microservices pros and cons - houston tech fest
 
Serverless in production, an experience report (London js community)
Serverless in production, an experience report (London js community)Serverless in production, an experience report (London js community)
Serverless in production, an experience report (London js community)
 
Building a CI/CD Pipeline for Containers - DevDay Los Angeles 2017
Building a CI/CD Pipeline for Containers - DevDay Los Angeles 2017Building a CI/CD Pipeline for Containers - DevDay Los Angeles 2017
Building a CI/CD Pipeline for Containers - DevDay Los Angeles 2017
 
There is No Server: Immutable Infrastructure and Serverless Architecture
There is No Server: Immutable Infrastructure and Serverless ArchitectureThere is No Server: Immutable Infrastructure and Serverless Architecture
There is No Server: Immutable Infrastructure and Serverless Architecture
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure Functions
 
(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy
(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy
(DEV302) Hosting ASP.Net 5 Apps in AWS with Docker & AWS CodeDeploy
 

Viewers also liked

Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!David Hoerster
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETDavid Hoerster
 
Building Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersBuilding Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersAnthony Brown
 
Streaming ETL With Akka.NET
Streaming ETL With Akka.NETStreaming ETL With Akka.NET
Streaming ETL With Akka.NETpetabridge
 
Distributed Transactions in Akka.NET
Distributed Transactions in Akka.NETDistributed Transactions in Akka.NET
Distributed Transactions in Akka.NETpetabridge
 
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir DresherFrom Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir DresherTamir Dresher
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleansBill Tulloch
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDDennis Doomen
 
F# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformF# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformHoward Mansell
 
CQRS basierte Architekturen mit Microservices
CQRS basierte Architekturen mit MicroservicesCQRS basierte Architekturen mit Microservices
CQRS basierte Architekturen mit MicroservicesMichael Plöd
 
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Building responsive applications with Rx  - CodeMash2017 - Tamir DresherBuilding responsive applications with Rx  - CodeMash2017 - Tamir Dresher
Building responsive applications with Rx - CodeMash2017 - Tamir DresherTamir Dresher
 
ASP.NET MVC Web API -twMVC#8
ASP.NET MVC Web API -twMVC#8ASP.NET MVC Web API -twMVC#8
ASP.NET MVC Web API -twMVC#8twMVC
 
Owin and-katana-overview
Owin and-katana-overviewOwin and-katana-overview
Owin and-katana-overviewsonia merchant
 
ASP.NET Web API O to 100
ASP.NET Web API O to 100ASP.NET Web API O to 100
ASP.NET Web API O to 100Himanshu Desai
 
Moving forward with ASP.NET Core
Moving forward with ASP.NET CoreMoving forward with ASP.NET Core
Moving forward with ASP.NET CoreEnea Gabriel
 
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Sergey Tihon
 

Viewers also liked (20)

Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
Drm and the web
Drm and the webDrm and the web
Drm and the web
 
Building Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software DevelopersBuilding Skynet: Machine Learning for Software Developers
Building Skynet: Machine Learning for Software Developers
 
Streaming ETL With Akka.NET
Streaming ETL With Akka.NETStreaming ETL With Akka.NET
Streaming ETL With Akka.NET
 
Distributed Transactions in Akka.NET
Distributed Transactions in Akka.NETDistributed Transactions in Akka.NET
Distributed Transactions in Akka.NET
 
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir DresherFrom Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleans
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDD
 
Der perfekte Microservice
Der perfekte MicroserviceDer perfekte Microservice
Der perfekte Microservice
 
F# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformF# Type Provider for R Statistical Platform
F# Type Provider for R Statistical Platform
 
CQRS basierte Architekturen mit Microservices
CQRS basierte Architekturen mit MicroservicesCQRS basierte Architekturen mit Microservices
CQRS basierte Architekturen mit Microservices
 
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Building responsive applications with Rx  - CodeMash2017 - Tamir DresherBuilding responsive applications with Rx  - CodeMash2017 - Tamir Dresher
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
 
ASP.NET MVC Web API -twMVC#8
ASP.NET MVC Web API -twMVC#8ASP.NET MVC Web API -twMVC#8
ASP.NET MVC Web API -twMVC#8
 
Owin and-katana-overview
Owin and-katana-overviewOwin and-katana-overview
Owin and-katana-overview
 
Owin e katana
Owin e katanaOwin e katana
Owin e katana
 
The Future of ASP.NET
The Future of ASP.NETThe Future of ASP.NET
The Future of ASP.NET
 
ASP.NET Web API O to 100
ASP.NET Web API O to 100ASP.NET Web API O to 100
ASP.NET Web API O to 100
 
Moving forward with ASP.NET Core
Moving forward with ASP.NET CoreMoving forward with ASP.NET Core
Moving forward with ASP.NET Core
 
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...
 

Similar to Creating scalable message driven solutions akkadotnet

Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .netMarco Parenzan
 
Akka Actors: an Introduction
Akka Actors: an IntroductionAkka Actors: an Introduction
Akka Actors: an IntroductionRoberto Casadei
 
Buiilding reactive distributed systems with Akka
Buiilding reactive distributed systems with AkkaBuiilding reactive distributed systems with Akka
Buiilding reactive distributed systems with AkkaJohan Andrén
 
Agile Development with OSGi
Agile Development with OSGiAgile Development with OSGi
Agile Development with OSGiMatt Stine
 
Reactive programming with akka
Reactive programming with akkaReactive programming with akka
Reactive programming with akkaWebdesign Factory
 
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...Codemotion
 
Beyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor ProgrammingBeyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor ProgrammingFabio Tiriticco
 
Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0Knoldus Inc.
 
Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Anna Shymchenko
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Esun Kim
 
From Elixir to Akka (and back) - ElixirConf Mx 2017
From Elixir to Akka (and back) - ElixirConf Mx 2017From Elixir to Akka (and back) - ElixirConf Mx 2017
From Elixir to Akka (and back) - ElixirConf Mx 2017Agustin Ramos
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
 
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016DevOpsDays Tel Aviv
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdfhamzadamani7
 
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYCBuilding a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYCKonrad Malawski
 

Similar to Creating scalable message driven solutions akkadotnet (20)

Developing Actors in Azure with .net
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
 
Akka Actors: an Introduction
Akka Actors: an IntroductionAkka Actors: an Introduction
Akka Actors: an Introduction
 
Buiilding reactive distributed systems with Akka
Buiilding reactive distributed systems with AkkaBuiilding reactive distributed systems with Akka
Buiilding reactive distributed systems with Akka
 
Agile Development with OSGi
Agile Development with OSGiAgile Development with OSGi
Agile Development with OSGi
 
Reactive programming with akka
Reactive programming with akkaReactive programming with akka
Reactive programming with akka
 
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
 
Beyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor ProgrammingBeyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor Programming
 
Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0
 
Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"Орхан Гасимов: "Reactive Applications in Java with Akka"
Орхан Гасимов: "Reactive Applications in Java with Akka"
 
Akka introtalk HyScala DEC 2016
Akka introtalk HyScala DEC 2016Akka introtalk HyScala DEC 2016
Akka introtalk HyScala DEC 2016
 
Akka framework
Akka frameworkAkka framework
Akka framework
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)
 
From Elixir to Akka (and back) - ElixirConf Mx 2017
From Elixir to Akka (and back) - ElixirConf Mx 2017From Elixir to Akka (and back) - ElixirConf Mx 2017
From Elixir to Akka (and back) - ElixirConf Mx 2017
 
Akka.Net & .Net Core - .Net Inside 4° MeetUp
Akka.Net & .Net Core - .Net Inside 4° MeetUpAkka.Net & .Net Core - .Net Inside 4° MeetUp
Akka.Net & .Net Core - .Net Inside 4° MeetUp
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
 
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
 
540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf540slidesofnodejsbackendhopeitworkforu.pdf
540slidesofnodejsbackendhopeitworkforu.pdf
 
Appengine Nljug
Appengine NljugAppengine Nljug
Appengine Nljug
 
Introducing Akka
Introducing AkkaIntroducing Akka
Introducing Akka
 
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYCBuilding a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
 

More from David Hoerster

Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?David Hoerster
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceDavid Hoerster
 
Freeing Yourself from an RDBMS Architecture
Freeing Yourself from an RDBMS ArchitectureFreeing Yourself from an RDBMS Architecture
Freeing Yourself from an RDBMS ArchitectureDavid Hoerster
 
A Minimalist’s Attempt at Building a Distributed Application
A Minimalist’s Attempt at Building a Distributed ApplicationA Minimalist’s Attempt at Building a Distributed Application
A Minimalist’s Attempt at Building a Distributed ApplicationDavid Hoerster
 
Greenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureGreenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureDavid Hoerster
 
jQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherjQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherDavid Hoerster
 

More from David Hoerster (7)

Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?Elm - Could this be the Future of Web Dev?
Elm - Could this be the Future of Web Dev?
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data Persistence
 
Mongo Baseball .NET
Mongo Baseball .NETMongo Baseball .NET
Mongo Baseball .NET
 
Freeing Yourself from an RDBMS Architecture
Freeing Yourself from an RDBMS ArchitectureFreeing Yourself from an RDBMS Architecture
Freeing Yourself from an RDBMS Architecture
 
A Minimalist’s Attempt at Building a Distributed Application
A Minimalist’s Attempt at Building a Distributed ApplicationA Minimalist’s Attempt at Building a Distributed Application
A Minimalist’s Attempt at Building a Distributed Application
 
Greenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows AzureGreenfield Development with CQRS and Windows Azure
Greenfield Development with CQRS and Windows Azure
 
jQuery and OData - Perfect Together
jQuery and OData - Perfect TogetherjQuery and OData - Perfect Together
jQuery and OData - Perfect Together
 

Recently uploaded

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 

Recently uploaded (20)

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 

Creating scalable message driven solutions akkadotnet

  • 1. CREATING SCALABLE MESSAGE- DRIVEN SOLUTIONS (WITH AKKA.NET) David Hoerster
  • 2. ABOUT ME 5-Time .NET (Visual C#) MVP (April 2011) Sr. Solutions Architect at Confluence One of the organizers for Pittsburgh TechFest (http://pghtechfest.com) Organizer of Pittsburgh Reactive Dev Group (http://meetup.com/reactive) Past President of Pittsburgh .NET Users Group Twitter - @DavidHoerster Blog – http://blog.agileways.com Email – david@agileways.com
  • 3. AGENDA Messages as Part of Application Design Being Reactive What the Actor Model Provides Hello Akka.NET Working with Akka.NET Cross-Process Actor Systems (Akka.Remote)
  • 4. CQRS Command Query Responsibility Segregation  Coined by Greg Young Evolution of CQS (Command Query Separation)  Coined by Bertrand Meyer Both revolve around the separation of writes (command) and reads (query) CQS is more at the unit level CQRS is at the bounded context level, or so
  • 5. MESSAGES The core of CQRS  Messages Communication from the service layer to the domain via commands  Command handlers could also update the underlying repository As actions happen, events are raised Event handlers could issue other commands Event handlers could update the underlying repository
  • 6. MESSAGES Regardless of how it’s implemented, communication between application parts is via messages Not only helps communicate intent of the action  “PublishWidget”, “ExpireWorkItem”, “UpdateDefinition”, “DefinitionUpdated” But allows for remote handling of messages  Queue, REST payload, etc.
  • 7. MESSAGES ARE KEY TO BEING REACTIVE
  • 8. SO? So how does this affect my system design? Let’s consider some procedural pitfalls
  • 9. WORD COUNTER EXAMPLE Simple program to count the occurrences of words in a document Print out the top 25 words and their counts at the end Can be accomplished easily via procedural code
  • 11. WORD COUNTER EXAMPLE What if you wanted to spread out the counting load? What if you wanted to scale out to other nodes/processes/machines? Fault tolerance, concurrent actions, etc.?
  • 12. BUILDING CONCURRENT APPS In word counter, may need to spawn some threads Lock some critical sections, etc. The system becomes responsible for knowing everything going on  Very Proactive (not Reactive!) system
  • 13. SIDE NOTE: REACTIVE VS. PROACTIVE Isn’t proactive a good thing? A system taking upon itself to check state is proactive  It’s doing too much A reactive system reacts to events that occur  It’s doing just the right amount
  • 14. SIDE NOTE: REACTIVE VS. PROACTIVE Isn’t proactive a good thing? A system taking upon itself to check state is proactive  It’s doing too much A reactive system reacts to events that occur  It’s doing just the right amount System EvtEvt System EvtEvt Proactive Reactive
  • 15. REAL WORLD SCENARIO Loosely structured data Multiple files to combine Operations to perform during the projection process
  • 16. REAL WORLD SCENARIO File File File Join Op Join/ End
  • 17. REAL WORLD SCENARIO Number of “steps” May need some sub-steps Can be broken down into individual pieces  Actors Communicate via messages for loose coupling
  • 18. REAL WORLD SCENARIO Actually looks like this: Multiple sources Several transforms Several joins Configurable
  • 19. ACTOR MODEL Actor Model is a system made of small units of concurrent computation  Formulated in the early 70’s Each unit is an actor Communicates to each other via messages Actors can have children, which they can supervise
  • 20. WHAT IS AN ACTOR? Class that encapsulates state and behavior  State can be persisted (Akka.Persistence)  Behavior can be switched (Become/Unbecome) Has a mailbox to receive messages  Ordered delivery by default  Queue Can create child actors Has a supervisory strategy for child actors  How to handle misbehaving children Are always thread safe Have a lifecycle  Started, stopped, restarted
  • 21. AKKA.NET Akka.NET is an open source framework Actor Model for .NET Port of Akka (for JVM/Scala) http://getakka.net NuGet package – search for Akka.Net (not the first result usually!)
  • 22. STARTING WITH AKKA.NET Akka.NET is a hierarchical system Root of the system is ActorSystem Expensive to instantiate – create and hold! ActorSystem can then be used to create Actors
  • 23. CREATING AN ACTOR An Actor has a unique address Can be accessed/communicated to like a URI Call ActorOf off ActorSystem, provide it a name  URI (actor path) is created hierarchically Actor Path = akka://myName/user/announcer
  • 24. SENDING A MESSAGE Messages are basis of actor communication  Should be IMMUTABLE!!! “Tell” an actor a message Async call  Immutable!!
  • 25. RECEIVING A MESSAGE Create your Actor Derive from ReceiveActor In constructor, register your message subscriptions
  • 26. RECEIVING A MESSAGE Each actor has a mailbox Messages are received in the actor’s mailbox (queue) Actor is notified that there’s a message  It receives the message  Takes it out of the mailbox  Next one is queued up Ordered delivery by default  Other mailboxes (like Priority) that are out-of-order Actor Mailbox Msg
  • 28. CREATING CHILDREN Best to call ActorOf to get an IActorRef Create a static Props creator Actor path is relative to parent’s actor path  akka://myDemo/user/countChocula/{childName} When creating a child, good idea to name it  So you can reference it later!
  • 29. WORD COUNTER WITH ACTORS Program sends StartCount message to CountSupervisor CountSupervisor, for each line, sends line to one of 5 LineCounterActors (ReadLineForCounting message) LineCounterActor counts the word in that line Tells the Sender (CountSupervisor) the results (MappedList message) CountSupervisor aggregates results of MappedList messages When all lines complete, CountSupervisor sends each LineActor a Complete message LineCounterActor cleans up and sends CountSupervisor Complete When all LineCounterActors are Complete, CountSupervisor prints out top 25 words
  • 31. ROUTING Map Reduce example used Round Robin There are others OOTB  Broadcast  Random  Consistent Hashing (used by Cluster)  Smallest Mailbox  More Pools and Groups  Pools are more anonymous  Groups are pre-created
  • 32. FINDING CHILDREN Within an actor, call Context.Child with the name of the child actor If not found, ActorRefs.Nobody is returned If found, you have an IActorRef to work with Using ActorSelection doesn’t guarantee actor is initialized
  • 33. MORE COMPLEX ACTOR DEMO baseball gameCoo rdinator gameInfo -x gameInfo -y playerSup ervisor batter-abatter-bbatter-c c-01 c-11 c-32
  • 34. INTEGRATION Integration with other systems is simple Best to encapsulate in its own actor Contain any errors there  Prevent affecting parts of the system further upstream
  • 35. ASYNC Actors have messages delivered to them in order via a Mailbox As message is received, handed to Actor to process Messages in mailbox queue up As a result, async processing of messages isn’t possible  Receive<> (async msg => { … }) doesn’t work If you need to perform async tasks within Receive  PipeTo(Self) usually does the trick  Re-queues message back on Mailbox  When delivered, actor resumes Actor Mailbox Msg PipeTo
  • 36. ACTORS ACROSS PROCESSES Akka.Remote module Configure via HOCON  Human Optimized Configuration Object Notation Allows an actor system to distribute messages to actors across processes Location transparency!!
  • 38. ACTORS ACROSS PROCESSES Actor Path modified  akka.tcp://localhost:50000@{system}/user/{supervisor}/{name} Protocol and location added to actor path Protocol defaults to tcp, but you can provide your own Actor path above is remote path
  • 40. ELASTICITY WITH ACTORS Akka.Cluster Multiple nodes of an actor system acting as one Allows for failure Can also expand out for performance
  • 41. SAVING ACTOR STATE Akka.Persistence Persist each message (or snapshots) to storage Like event sourcing Rehydrate actor state after failure or for whatever reason
  • 42. ASKING AN ACTOR Wait for a response from an actor Somewhat of an anti-pattern for Actor Model If used, use sparingly
  • 43. HANDLING ERRORS An exception during processing with a classic app could crash the whole system An exception within a child actor is isolated
  • 44. IS AKKA.NET…? Pub/Sub?  No, but it could be Message Bus, like RabbitMQ or MassTransit  Uses messages to communicate  Message bus concerned with building a distributed system topology Storm, ETL/ELT, etc.?  Kind of  Can build system like that with Akka.NET