SlideShare a Scribd company logo
1 of 34
Download to read offline
Presented By: Mansi Babbar &
Bhavya Verma
Dive Into Akka Actors
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Respect Knolx session timings, you
are requested not to join sessions
after a 5 minutes threshold post
the session start time.
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Mute
Please keep your window on mute
Avoid Disturbance
Avoid leaving your window
unmuted after asking a question
Agenda
01 Limitations of Multithreading Model
02 Why Akka Actors?
04 Communicating with Actors
05 Changing Actor Behaviour
06 Creating Child Actors
05 Actor Life Cycle
07
7
Creating Actors
03
Agenda
08 Actors Supervision Strategy
09 Akka Infrastructure
Limitations of
Multithreading Model
Limitations of Multithreading Model
● OOP encapsulation is only valid in a single threaded model.
● Delegating something to a thread is a very difficult task.
● Difficult to trace and deal with errors in a multithreading environment.
Why Akka Actors?
Why Akka Actors?
● Actors inspire Object-oriented paradigm.
● Just like traditional objects, actors also store their state as data.
● Actors are objects we can’t access directly, but only send messages to.
● Actors interact via sending and receiving messages.
● Messages are asynchronous by nature.
Creating and
Instantiating Actors
Creating and Instantiating Actors
● Actor system is heavy weight data structure.
● Actor system controls the number of threads and allocates them to running actors.
● Actor is a data structure that needs a thread to run.
● Actors are uniquely identified.
● Definition of actor has some internal data and behaviour(receive handler).
● Each actor has unique behaviour of processing the messages.
● Every actor must override receive() method.
● Messages are passed asynchronously among actors.
Creating and Instantiating Actors
● Actors are instantiated by calling actorOf() method in the actor system.
● Actor reference is a data structure provided by Akka to prohibit direct access of
actor instance created by Akka.
● Actors can communicate via actor references only.
● Props object is data structure that is used to create actor reference.
Communicating with
Actors
Communicating with Actors
● Akka sends messages to actors asynchronously.
● Actors send messages to each other via actor references.
● tell(!) method is invoked to send message to an actor.
● Messages can be of any type.
● We can send any message under two conditions:
○ Messages must be immutable.
○ Messages must be serializable.
Communicating with Actors
● Each actor has a member called context. It holds the information about the actor
environment.
● context.self is used by actor to send messages to itself.
● context.sender() returns ActorRef to send a message back to sender.
● When a message is sent to an actor from main application, the sender() is
Actor.noSender
● DeadLetters is an inbuilt actor of Akka that receives messages which are not sent to
anyone. It is the garbage pool of messages.
Communicating with Actors
● forward method is invoked to send a message to an actorRef by keeping the
original sender.
● Return type of receive() is Receive. It is an alias of a partial function from Any to Unit.
● Each actor has message handler and mail box in which messages are enqueued.
● Akka provides following message delivery guarantees:
○ AtmostOnce Message Delivery
○ AtleastOnce Message Delivery
○ ExactlyOnce Message Delivery
Changing Actor
Behavior
Changing Actor Behavior
● Akka provides the ability to change Actor behavior defined in message handlers.
● We should create stateless actors, because state of an actor can be complex and it
can cause mutability.
● To change actor behavior, implement separate message and handlers and swap
between them based on requirement.
● We use context.become() and context.unbecome() to get rid of actor's mutable state,
by changing actor behavior as responses to messages.
Creating Child Actors
Creating Child Actors
● Actors can create other other actors by using actor's context, i.e. by invoking
context.actorOf().
● Child actor's name is appended to parent actor's path.
● Akka provides the ability of creating actor hierarchies by using feature of child
creation.
● Every Akka actor system has 3 guardian actors:
○ System guardian
○ User guardian
○ Root guardian
Creating Child Actors
● Akka provides the feature of Actor selection. It is a wrapper over a potential
ActorRef which is used to send a message.
● We can locate an actor using actor selection by providing path of that actor.
● Actor selection is created by using system.actorSelection(path) and passing a path as
a string.
Actor Life Cycle
Stopping Actors
Two ways to stop an actor:
i. Calling stop method - system.stop() or context.stop()
It is a non blocking process. It means that it doesn’t stop immediately. The
actor may process some messages even after sending the stop signal.
ii. Sending special messages - PosionPill or Kill
PoisonPill simply invokes the stopping procedure. Kill is more brutal than
PoisonPill as it makes an actor throw ActorKilledException.
Death Watch
● It is a mechanism to be notified when an actor dies.
● Method we use for death watch:
i. context.watch()
It registers the actor for death watch. When an actor dies, the watcher
actor who has registered for the death watch receives a special
Terminated message.
ii. context.unwatch()
It unregisters the actor for death watch.
Supervision Strategy
● Parents must decide upon their child's failure with a supervision strategy.
● When an actor fails, it suspends all of its children and sends a special
message to its parent.
● Parent can decide to:
○ resume the actor
○ restart the actor
○ stop the actor
○ escalate and fail itself
Supervision Strategy
● Supervision strategies:
○ OneForOneStrategy
It is applied to the exact actor which caused the failure
○ AllForOneStrategy
It is applied to all the actors regardless of one that actually caused the
failure
Supervision Strategy
Akka Infrastructure
Schedulers
● We can schedule messages to run at a defined point in the future using:
○ scheduleOnce(initial delay) to schedule a message once
○ schedule(initial delay, interval) to schedule messages repeatedly
● We can also define cancellable which means that we can schedule the
message to cancel at some time using schedule.cancel()
Routers
● Routers are useful when you want to delegate or spread work in between
multiple actors of the same kind.
● Routers are usually middle level actors that forward messages to other actors
which are called routees, either created by the routers themselves or from
the outside.
Routers
● Some routing logics:
○ Round-robin - which cycles between routees
○ Random - which picks routers randomly
○ Smallest mailbox - which sends next message to the actor with fewest
messages in the queue.
○ Broadcast - which send messages to all the routers
○ Scatter-gather-first - which do a broadcast and waits for first reply and
rest of the replies are discarded.
● Mailboxes are data structures in the actor reference that store messages.
● Types of mailboxes:
○ Custom priority mailbox - messages are stored in mailbox on the basis of
their priority.
○ Control-aware mailbox - some messages need to be processed first
regardless of what has been queued in the mailbox. We make those
messages as control messages.
Mailboxes
Demo
Thank You !

More Related Content

What's hot

Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and AkkaYung-Lin Ho
 
Concurrency in Scala
Concurrency in ScalaConcurrency in Scala
Concurrency in ScalaKnoldus Inc.
 
High Level Server API - Akka Http.pdf
High Level Server API - Akka Http.pdfHigh Level Server API - Akka Http.pdf
High Level Server API - Akka Http.pdfKnoldus Inc.
 
Globant development week / React Redux Rorkshop
Globant development week / React Redux RorkshopGlobant development week / React Redux Rorkshop
Globant development week / React Redux RorkshopGlobant
 
Introduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingIntroduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingĐặng Thái Sơn
 
Scala Italy 2015 - An Introduction to Akka and the Actor Based Model
Scala Italy 2015 - An Introduction to Akka and the Actor Based ModelScala Italy 2015 - An Introduction to Akka and the Actor Based Model
Scala Italy 2015 - An Introduction to Akka and the Actor Based ModelDaniela Sfregola
 
Java threads
Java threadsJava threads
Java threadsjavaicon
 
Backslant or python templates engines design guidelines.
Backslant or python templates engines design guidelines.Backslant or python templates engines design guidelines.
Backslant or python templates engines design guidelines.Mikhail Krivushin
 
Fundamentals of Akka - Webinar
Fundamentals of Akka - WebinarFundamentals of Akka - Webinar
Fundamentals of Akka - WebinarKnoldus Inc.
 
Tech Talk #4 : Functional Reactive Programming - Đặng Thái Sơn
Tech Talk #4 : Functional Reactive Programming - Đặng Thái SơnTech Talk #4 : Functional Reactive Programming - Đặng Thái Sơn
Tech Talk #4 : Functional Reactive Programming - Đặng Thái SơnNexus FrontierTech
 
Understanding concurrency
Understanding concurrencyUnderstanding concurrency
Understanding concurrencyAnshul Sharma
 
Trailblazer Rails Architecture
Trailblazer Rails ArchitectureTrailblazer Rails Architecture
Trailblazer Rails Architectureiqbal hasnan
 
Before you jump into Angular
Before you jump into AngularBefore you jump into Angular
Before you jump into AngularM A Hossain Tonu
 
C#: Understanding ConfigureAwait(false)
C#: Understanding ConfigureAwait(false)C#: Understanding ConfigureAwait(false)
C#: Understanding ConfigureAwait(false)Shuhei Eda
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - TalkMatthias Noback
 

What's hot (20)

Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
 
Concurrency in Scala
Concurrency in ScalaConcurrency in Scala
Concurrency in Scala
 
High Level Server API - Akka Http.pdf
High Level Server API - Akka Http.pdfHigh Level Server API - Akka Http.pdf
High Level Server API - Akka Http.pdf
 
Globant development week / React Redux Rorkshop
Globant development week / React Redux RorkshopGlobant development week / React Redux Rorkshop
Globant development week / React Redux Rorkshop
 
Introduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingIntroduction to Functional Reactive Programming
Introduction to Functional Reactive Programming
 
Scala Italy 2015 - An Introduction to Akka and the Actor Based Model
Scala Italy 2015 - An Introduction to Akka and the Actor Based ModelScala Italy 2015 - An Introduction to Akka and the Actor Based Model
Scala Italy 2015 - An Introduction to Akka and the Actor Based Model
 
Java threads
Java threadsJava threads
Java threads
 
Backslant or python templates engines design guidelines.
Backslant or python templates engines design guidelines.Backslant or python templates engines design guidelines.
Backslant or python templates engines design guidelines.
 
Fundamentals of Akka - Webinar
Fundamentals of Akka - WebinarFundamentals of Akka - Webinar
Fundamentals of Akka - Webinar
 
RxSwift
RxSwiftRxSwift
RxSwift
 
Tech Talk #4 : Functional Reactive Programming - Đặng Thái Sơn
Tech Talk #4 : Functional Reactive Programming - Đặng Thái SơnTech Talk #4 : Functional Reactive Programming - Đặng Thái Sơn
Tech Talk #4 : Functional Reactive Programming - Đặng Thái Sơn
 
Understanding concurrency
Understanding concurrencyUnderstanding concurrency
Understanding concurrency
 
Trailblazer Rails Architecture
Trailblazer Rails ArchitectureTrailblazer Rails Architecture
Trailblazer Rails Architecture
 
Patterns in JavaScript
Patterns in JavaScriptPatterns in JavaScript
Patterns in JavaScript
 
Before you jump into Angular
Before you jump into AngularBefore you jump into Angular
Before you jump into Angular
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Akka framework
Akka frameworkAkka framework
Akka framework
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
C#: Understanding ConfigureAwait(false)
C#: Understanding ConfigureAwait(false)C#: Understanding ConfigureAwait(false)
C#: Understanding ConfigureAwait(false)
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 

Similar to Dive into Akka Actors

Introduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actorsIntroduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actorsdatamantra
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsShashank L
 
Building stateful systems with akka cluster sharding
Building stateful systems with akka cluster shardingBuilding stateful systems with akka cluster sharding
Building stateful systems with akka cluster shardingKnoldus Inc.
 
Scala laboratory: Globus. iteration #3
Scala laboratory: Globus. iteration #3Scala laboratory: Globus. iteration #3
Scala laboratory: Globus. iteration #3Vasil Remeniuk
 
Actor based architecture for world's largest telescope
Actor based architecture for world's largest telescopeActor based architecture for world's largest telescope
Actor based architecture for world's largest telescopeskvithalani
 
Introduction to Akka Cluster Sharding
Introduction to Akka Cluster ShardingIntroduction to Akka Cluster Sharding
Introduction to Akka Cluster ShardingKnoldus Inc.
 
Reactive programming with akka
Reactive programming with akka Reactive programming with akka
Reactive programming with akka Sovon Nath
 
Reactive Programming in Akka
Reactive Programming in AkkaReactive Programming in Akka
Reactive Programming in AkkaDevFest DC
 
Working With Child Actors in Akka
Working With Child Actors in AkkaWorking With Child Actors in Akka
Working With Child Actors in AkkaKnoldus Inc.
 
Working With Child Actors in Akka
Working With Child Actors in AkkaWorking With Child Actors in Akka
Working With Child Actors in AkkaKnoldus Inc.
 
Akka-intro-training-public.pdf
Akka-intro-training-public.pdfAkka-intro-training-public.pdf
Akka-intro-training-public.pdfBernardDeffarges
 
Reactive mistakes - ScalaDays Chicago 2017
Reactive mistakes -  ScalaDays Chicago 2017Reactive mistakes -  ScalaDays Chicago 2017
Reactive mistakes - ScalaDays Chicago 2017Petr Zapletal
 
Oop2011 actor presentation_stal
Oop2011 actor presentation_stalOop2011 actor presentation_stal
Oop2011 actor presentation_stalMichael Stal
 
Actor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupActor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupNATS
 
Actor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupActor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupApcera
 
Apache Airflow | What Is An Operator
Apache Airflow | What Is An OperatorApache Airflow | What Is An Operator
Apache Airflow | What Is An OperatorMarc Lamberti
 

Similar to Dive into Akka Actors (20)

Introduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actorsIntroduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actors
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
 
Building stateful systems with akka cluster sharding
Building stateful systems with akka cluster shardingBuilding stateful systems with akka cluster sharding
Building stateful systems with akka cluster sharding
 
Actor Model Akka Framework
Actor Model Akka FrameworkActor Model Akka Framework
Actor Model Akka Framework
 
Scala laboratory: Globus. iteration #3
Scala laboratory: Globus. iteration #3Scala laboratory: Globus. iteration #3
Scala laboratory: Globus. iteration #3
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
 
Actor based architecture for world's largest telescope
Actor based architecture for world's largest telescopeActor based architecture for world's largest telescope
Actor based architecture for world's largest telescope
 
Introduction to Akka Cluster Sharding
Introduction to Akka Cluster ShardingIntroduction to Akka Cluster Sharding
Introduction to Akka Cluster Sharding
 
Actors in the Small
Actors in the SmallActors in the Small
Actors in the Small
 
Reactive programming with akka
Reactive programming with akka Reactive programming with akka
Reactive programming with akka
 
Reactive Programming in Akka
Reactive Programming in AkkaReactive Programming in Akka
Reactive Programming in Akka
 
Working With Child Actors in Akka
Working With Child Actors in AkkaWorking With Child Actors in Akka
Working With Child Actors in Akka
 
Working With Child Actors in Akka
Working With Child Actors in AkkaWorking With Child Actors in Akka
Working With Child Actors in Akka
 
Akka Actors
Akka ActorsAkka Actors
Akka Actors
 
Akka-intro-training-public.pdf
Akka-intro-training-public.pdfAkka-intro-training-public.pdf
Akka-intro-training-public.pdf
 
Reactive mistakes - ScalaDays Chicago 2017
Reactive mistakes -  ScalaDays Chicago 2017Reactive mistakes -  ScalaDays Chicago 2017
Reactive mistakes - ScalaDays Chicago 2017
 
Oop2011 actor presentation_stal
Oop2011 actor presentation_stalOop2011 actor presentation_stal
Oop2011 actor presentation_stal
 
Actor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupActor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder Meetup
 
Actor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupActor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder Meetup
 
Apache Airflow | What Is An Operator
Apache Airflow | What Is An OperatorApache Airflow | What Is An Operator
Apache Airflow | What Is An Operator
 

More from Knoldus Inc.

Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationKnoldus Inc.
 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxKnoldus Inc.
 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxKnoldus Inc.
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)Knoldus Inc.
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxKnoldus Inc.
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingKnoldus Inc.
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionKnoldus Inc.
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxKnoldus Inc.
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptxKnoldus Inc.
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfKnoldus Inc.
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxKnoldus Inc.
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingKnoldus Inc.
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesKnoldus Inc.
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxKnoldus Inc.
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxKnoldus Inc.
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxKnoldus Inc.
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxKnoldus Inc.
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxKnoldus Inc.
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationKnoldus Inc.
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationKnoldus Inc.
 

More from Knoldus Inc. (20)

Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable Testing
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose Kubernetes
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptx
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptx
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptx
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptx
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake Presentation
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics Presentation
 

Recently uploaded

Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)Wonjun Hwang
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch TuesdayIvanti
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfOverkill Security
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?Paolo Missier
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistandanishmna97
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 

Recently uploaded (20)

Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)CORS (Kitworks Team Study 양다윗 발표자료 240510)
CORS (Kitworks Team Study 양다윗 발표자료 240510)
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 

Dive into Akka Actors

  • 1. Presented By: Mansi Babbar & Bhavya Verma Dive Into Akka Actors
  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes Punctuality Respect Knolx session timings, you are requested not to join sessions after a 5 minutes threshold post the session start time. Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Mute Please keep your window on mute Avoid Disturbance Avoid leaving your window unmuted after asking a question
  • 3. Agenda 01 Limitations of Multithreading Model 02 Why Akka Actors? 04 Communicating with Actors 05 Changing Actor Behaviour 06 Creating Child Actors 05 Actor Life Cycle 07 7 Creating Actors 03
  • 4. Agenda 08 Actors Supervision Strategy 09 Akka Infrastructure
  • 6. Limitations of Multithreading Model ● OOP encapsulation is only valid in a single threaded model. ● Delegating something to a thread is a very difficult task. ● Difficult to trace and deal with errors in a multithreading environment.
  • 8. Why Akka Actors? ● Actors inspire Object-oriented paradigm. ● Just like traditional objects, actors also store their state as data. ● Actors are objects we can’t access directly, but only send messages to. ● Actors interact via sending and receiving messages. ● Messages are asynchronous by nature.
  • 10. Creating and Instantiating Actors ● Actor system is heavy weight data structure. ● Actor system controls the number of threads and allocates them to running actors. ● Actor is a data structure that needs a thread to run. ● Actors are uniquely identified. ● Definition of actor has some internal data and behaviour(receive handler). ● Each actor has unique behaviour of processing the messages. ● Every actor must override receive() method. ● Messages are passed asynchronously among actors.
  • 11. Creating and Instantiating Actors ● Actors are instantiated by calling actorOf() method in the actor system. ● Actor reference is a data structure provided by Akka to prohibit direct access of actor instance created by Akka. ● Actors can communicate via actor references only. ● Props object is data structure that is used to create actor reference.
  • 13. Communicating with Actors ● Akka sends messages to actors asynchronously. ● Actors send messages to each other via actor references. ● tell(!) method is invoked to send message to an actor. ● Messages can be of any type. ● We can send any message under two conditions: ○ Messages must be immutable. ○ Messages must be serializable.
  • 14. Communicating with Actors ● Each actor has a member called context. It holds the information about the actor environment. ● context.self is used by actor to send messages to itself. ● context.sender() returns ActorRef to send a message back to sender. ● When a message is sent to an actor from main application, the sender() is Actor.noSender ● DeadLetters is an inbuilt actor of Akka that receives messages which are not sent to anyone. It is the garbage pool of messages.
  • 15. Communicating with Actors ● forward method is invoked to send a message to an actorRef by keeping the original sender. ● Return type of receive() is Receive. It is an alias of a partial function from Any to Unit. ● Each actor has message handler and mail box in which messages are enqueued. ● Akka provides following message delivery guarantees: ○ AtmostOnce Message Delivery ○ AtleastOnce Message Delivery ○ ExactlyOnce Message Delivery
  • 17. Changing Actor Behavior ● Akka provides the ability to change Actor behavior defined in message handlers. ● We should create stateless actors, because state of an actor can be complex and it can cause mutability. ● To change actor behavior, implement separate message and handlers and swap between them based on requirement. ● We use context.become() and context.unbecome() to get rid of actor's mutable state, by changing actor behavior as responses to messages.
  • 19. Creating Child Actors ● Actors can create other other actors by using actor's context, i.e. by invoking context.actorOf(). ● Child actor's name is appended to parent actor's path. ● Akka provides the ability of creating actor hierarchies by using feature of child creation. ● Every Akka actor system has 3 guardian actors: ○ System guardian ○ User guardian ○ Root guardian
  • 20. Creating Child Actors ● Akka provides the feature of Actor selection. It is a wrapper over a potential ActorRef which is used to send a message. ● We can locate an actor using actor selection by providing path of that actor. ● Actor selection is created by using system.actorSelection(path) and passing a path as a string.
  • 22.
  • 23. Stopping Actors Two ways to stop an actor: i. Calling stop method - system.stop() or context.stop() It is a non blocking process. It means that it doesn’t stop immediately. The actor may process some messages even after sending the stop signal. ii. Sending special messages - PosionPill or Kill PoisonPill simply invokes the stopping procedure. Kill is more brutal than PoisonPill as it makes an actor throw ActorKilledException.
  • 24. Death Watch ● It is a mechanism to be notified when an actor dies. ● Method we use for death watch: i. context.watch() It registers the actor for death watch. When an actor dies, the watcher actor who has registered for the death watch receives a special Terminated message. ii. context.unwatch() It unregisters the actor for death watch.
  • 26. ● Parents must decide upon their child's failure with a supervision strategy. ● When an actor fails, it suspends all of its children and sends a special message to its parent. ● Parent can decide to: ○ resume the actor ○ restart the actor ○ stop the actor ○ escalate and fail itself Supervision Strategy
  • 27. ● Supervision strategies: ○ OneForOneStrategy It is applied to the exact actor which caused the failure ○ AllForOneStrategy It is applied to all the actors regardless of one that actually caused the failure Supervision Strategy
  • 29. Schedulers ● We can schedule messages to run at a defined point in the future using: ○ scheduleOnce(initial delay) to schedule a message once ○ schedule(initial delay, interval) to schedule messages repeatedly ● We can also define cancellable which means that we can schedule the message to cancel at some time using schedule.cancel()
  • 30. Routers ● Routers are useful when you want to delegate or spread work in between multiple actors of the same kind. ● Routers are usually middle level actors that forward messages to other actors which are called routees, either created by the routers themselves or from the outside.
  • 31. Routers ● Some routing logics: ○ Round-robin - which cycles between routees ○ Random - which picks routers randomly ○ Smallest mailbox - which sends next message to the actor with fewest messages in the queue. ○ Broadcast - which send messages to all the routers ○ Scatter-gather-first - which do a broadcast and waits for first reply and rest of the replies are discarded.
  • 32. ● Mailboxes are data structures in the actor reference that store messages. ● Types of mailboxes: ○ Custom priority mailbox - messages are stored in mailbox on the basis of their priority. ○ Control-aware mailbox - some messages need to be processed first regardless of what has been queued in the mailbox. We make those messages as control messages. Mailboxes
  • 33. Demo