SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
Introduction to Akka
(for Scala infants !!!!)
-------
Prasanna Kumar
Excuse me !!!!!
I assume that you ,,,,
already stepped in to "Scala"land and its a JVM
language
written some Scala code and understand its
fundementals
familiar with SBT (like maven)
About this talk
is
for "Impatient"
help you to write Akka Code "right now" in
Scala
distinguish Actor model and Akka
not
teaching the partial functions and algebraic
data types in Scala
cover all aspects of Akka
Agenda
What makes us to consider Actor Model
Understanding Actor model of programming
Introducing to Akka
Akka Actor model approach
Setting up
Writing Actors using Akka (with code examples)
Moving forward (touchbase)
Q&A
What makes us to consider Actor
Model
Modern day programming need to process lot of
data in terms of
- volume
- variety
- velocity
our code started to use multiple CPU cores within
the machine or across a cluster
What makes us to consider Actor
Model (contd)
Obvious option is to consider aysnc programming
with "threads"
(atleast in Java) programming for threads is a
cumbersome
requires a lot of boiler-plate code
communicaiton between threads (with in and
outside JVM) is tedious
What makes us to consider Actor
Model (contd)
does this means the thread model is broken ??
No .. but it serves as a good foundation
just that it need better async abstraction
So how do we solve this ?
for writing concurrent and distributed programs,
we need threads to communicate easily
"Actor Model" to the rescue
What is an Actor
this model prescribes an "Actor" backed by a
thread model (by the underlying runtime or OS)
Async abstraction can be expressed as an actor in
the form of Class or function
an Actor framework
can create & manage actor
clients can communicate only by passing messages
(Async'ly) to the actor
actors can also communicate between themselves
What is an Actor
unlike Thread, an Actor
message driven
responds to certain messages from other Actors
(or non-actors)
can handle only one message at any instant of
time
Actor model of programming (contd)
Introducing Akka
Scala/Java API whcih implements the Actor model
provides a framework to create & manage actors ,
backed by JVM Thread model
Akka provides a mailbox for each actor : in-
memory queue to stage messages
clients acan send messages either by
! send or ? ask pattern (more on that later)
actor reveives messages and respond to clients
Akka actors use pattern matching to hande
messages
Lets start coding
Setting up
sbt co-ordinates
in build.sbt
name := "hyscala-akka-intro-talk"
version := "1.0"
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.4.14")
open the project in your IDE to get started
plain simple actor
class PlainActor extends Actor {
def receive: Receive = {
case _ =>
}
}
actor which can respond to some messages:
class PrimitiveHandlingActor extends Actor {
def receive: Receive = {
case "hello world" => println("""received hello world """)
case 11 => println("received ")
case _ => println("some other data type")
}
}
simple shopping cart
cart and order as two actors
show case their interaction with simple messages
covers actor to actor message passing
Messages
case class Item(name: String, quantity: Int,
rate: Double)
case object Done
case class Order(item: List[Item])
Cart Actor
class CartActor extends Actor {
val items = ListBuffer[Item]()
def receive: Receive = {
case item: Item => items.+=(item)
// done with adding items to cart
case Done => ???
}
}
Cart Actor - next version
class CartActor(billingActor: ActorRef) extends Actor {
...
case Done =>
billingActor ! Order(items.toList)
items.clear()
}
Billing Actor
class BilingActor extends Actor {
def receive: Receive = {
case order: Order =>
println(s"Here your bill ${Bill(order.items.foldLeft(0.0)((a
}
}
all together ....
ouput:
Here your bill Bill(175.0)
object AkkaIntroTalk extends App {
val actorSystem = ActorSystem("actorsystem")
val billingActor = actorSystem.actorOf(Props[BillingActor],
val cartActor = actorSystem.actorOf(Props(classOf[CartAct
cartActor ! Item("Apple", 3, 20.0)
cartActor ! Item("Orange", 3, 15.0)
cartActor ! Item("Butter", 1, 70.0)
cartActor ! Done
}
Learning Akka
Online
Akka Docs
Let it crash - blog
Books
Learning Akka
Reactive Programming with Scala and Akka -
(I've authored this book)
Moving forward (touchbase)
Actor heirarchy
FSM
Load Balacing
Akka Clustering
Akka HTTP
Takeaway
https://github.com/prassee/hyscala-akka-intro-
talk/tree/master
Q&A
Akka introtalk HyScala DEC 2016

Mais conteúdo relacionado

Mais procurados

Zend Studio Tips and Tricks
Zend Studio Tips and TricksZend Studio Tips and Tricks
Zend Studio Tips and TricksRoy Ganor
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
8 introduction to_java_script
8 introduction to_java_script8 introduction to_java_script
8 introduction to_java_scriptVijay Kalyan
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
javascript
javascript javascript
javascript Kaya Ota
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
 
Virtual function and abstract class
Virtual function and abstract classVirtual function and abstract class
Virtual function and abstract classShweta Shah
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java DevelopersYakov Fain
 
IOS Swift language 2nd tutorial
IOS Swift language 2nd tutorialIOS Swift language 2nd tutorial
IOS Swift language 2nd tutorialHassan A-j
 

Mais procurados (20)

Zend Studio Tips and Tricks
Zend Studio Tips and TricksZend Studio Tips and Tricks
Zend Studio Tips and Tricks
 
Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
 
Use the @types, Luke
Use the @types, LukeUse the @types, Luke
Use the @types, Luke
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Books
BooksBooks
Books
 
Javascript
JavascriptJavascript
Javascript
 
C#/.NET Little Pitfalls
C#/.NET Little PitfallsC#/.NET Little Pitfalls
C#/.NET Little Pitfalls
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
8 introduction to_java_script
8 introduction to_java_script8 introduction to_java_script
8 introduction to_java_script
 
Javascript
JavascriptJavascript
Javascript
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
javascript
javascript javascript
javascript
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
 
Virtual function and abstract class
Virtual function and abstract classVirtual function and abstract class
Virtual function and abstract class
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
 
IOS Swift language 2nd tutorial
IOS Swift language 2nd tutorialIOS Swift language 2nd tutorial
IOS Swift language 2nd tutorial
 
Javascript
JavascriptJavascript
Javascript
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
 
Java script
Java scriptJava script
Java script
 

Destaque

Deep Introduction to Akka
Deep Introduction to AkkaDeep Introduction to Akka
Deep Introduction to Akkapatriknw
 
Akka/Actor introduction
Akka/Actor introductionAkka/Actor introduction
Akka/Actor introductionYuki Katada
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to AkkaPiotr Trzpil
 
An Introduction to Akka
An Introduction to AkkaAn Introduction to Akka
An Introduction to AkkaSoftwareMill
 
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupRoy Russo
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentationGene Chang
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to AkkaJohan Andrén
 
An Introduction to Akka http
An Introduction to Akka httpAn Introduction to Akka http
An Introduction to Akka httpKnoldus Inc.
 
ITFT_Inter process communication
ITFT_Inter process communicationITFT_Inter process communication
ITFT_Inter process communicationSneh Prabha
 
The Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyThe Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyDror Bereznitsky
 

Destaque (10)

Deep Introduction to Akka
Deep Introduction to AkkaDeep Introduction to Akka
Deep Introduction to Akka
 
Akka/Actor introduction
Akka/Actor introductionAkka/Actor introduction
Akka/Actor introduction
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to Akka
 
An Introduction to Akka
An Introduction to AkkaAn Introduction to Akka
An Introduction to Akka
 
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users Group
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentation
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to Akka
 
An Introduction to Akka http
An Introduction to Akka httpAn Introduction to Akka http
An Introduction to Akka http
 
ITFT_Inter process communication
ITFT_Inter process communicationITFT_Inter process communication
ITFT_Inter process communication
 
The Actor Model - Towards Better Concurrency
The Actor Model - Towards Better ConcurrencyThe Actor Model - Towards Better Concurrency
The Actor Model - Towards Better Concurrency
 

Semelhante a Akka introtalk HyScala DEC 2016

Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matterSkills Matter
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with AkkaMaciej Matyjas
 
Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Konrad Malawski
 
Building Stateful Microservices With Akka
Building Stateful Microservices With AkkaBuilding Stateful Microservices With Akka
Building Stateful Microservices With AkkaYaroslav Tkachenko
 
Anatomy of a Reactive Application
Anatomy of a Reactive ApplicationAnatomy of a Reactive Application
Anatomy of a Reactive ApplicationMark Wilson
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency ConstructsTed Leung
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And DesignYaroslav Tkachenko
 
Actor based approach in practice for Swift developers
Actor based approach in practice for Swift developersActor based approach in practice for Swift developers
Actor based approach in practice for Swift developersBartosz Polaczyk
 
Build Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuBuild Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuSalesforce Developers
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Languageleague
 
On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009Michael Neale
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSAlberto Paro
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsScala Italy
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationAjax Experience 2009
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express jsAhmed Assaf
 
Concurrency Constructs Overview
Concurrency Constructs OverviewConcurrency Constructs Overview
Concurrency Constructs Overviewstasimus
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
 
Moderne backends mit dem aktor programmiermodell
Moderne backends mit dem aktor programmiermodellModerne backends mit dem aktor programmiermodell
Moderne backends mit dem aktor programmiermodellDamir Dobric
 
Elasticsearch And Apache Lucene For Apache Spark And MLlib
Elasticsearch And Apache Lucene For Apache Spark And MLlibElasticsearch And Apache Lucene For Apache Spark And MLlib
Elasticsearch And Apache Lucene For Apache Spark And MLlibJen Aman
 

Semelhante a Akka introtalk HyScala DEC 2016 (20)

Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with Akka
 
Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018Networks and Types - the Future of Akka @ ScalaDays NYC 2018
Networks and Types - the Future of Akka @ ScalaDays NYC 2018
 
Building Stateful Microservices With Akka
Building Stateful Microservices With AkkaBuilding Stateful Microservices With Akka
Building Stateful Microservices With Akka
 
Anatomy of a Reactive Application
Anatomy of a Reactive ApplicationAnatomy of a Reactive Application
Anatomy of a Reactive Application
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
 
A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
 
Actor based approach in practice for Swift developers
Actor based approach in practice for Swift developersActor based approach in practice for Swift developers
Actor based approach in practice for Swift developers
 
Build Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuBuild Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and Heroku
 
The Scala Programming Language
The Scala Programming LanguageThe Scala Programming Language
The Scala Programming Language
 
On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus Presentation
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Concurrency Constructs Overview
Concurrency Constructs OverviewConcurrency Constructs Overview
Concurrency Constructs Overview
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
Moderne backends mit dem aktor programmiermodell
Moderne backends mit dem aktor programmiermodellModerne backends mit dem aktor programmiermodell
Moderne backends mit dem aktor programmiermodell
 
Elasticsearch And Apache Lucene For Apache Spark And MLlib
Elasticsearch And Apache Lucene For Apache Spark And MLlibElasticsearch And Apache Lucene For Apache Spark And MLlib
Elasticsearch And Apache Lucene For Apache Spark And MLlib
 

Mais de PrasannaKumar Sathyanarayanan (10)

Akka fsm presentation
Akka fsm presentationAkka fsm presentation
Akka fsm presentation
 
Cps (continuation passing style) in scala
Cps (continuation passing style) in scalaCps (continuation passing style) in scala
Cps (continuation passing style) in scala
 
Introduction to akka chense
Introduction to akka   chenseIntroduction to akka   chense
Introduction to akka chense
 
Finagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvmFinagle - an intro to rpc & a sync programming in jvm
Finagle - an intro to rpc & a sync programming in jvm
 
Websocket,JSON in JEE7
Websocket,JSON in JEE7Websocket,JSON in JEE7
Websocket,JSON in JEE7
 
Scala Introduction with play - for my CSS nerds
Scala Introduction with play - for my CSS nerdsScala Introduction with play - for my CSS nerds
Scala Introduction with play - for my CSS nerds
 
CDI in JEE6
CDI in JEE6CDI in JEE6
CDI in JEE6
 
Ejb3.1
Ejb3.1Ejb3.1
Ejb3.1
 
Producer consumerproblem
Producer consumerproblemProducer consumerproblem
Producer consumerproblem
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Akka introtalk HyScala DEC 2016

  • 1. Introduction to Akka (for Scala infants !!!!) ------- Prasanna Kumar
  • 2. Excuse me !!!!! I assume that you ,,,, already stepped in to "Scala"land and its a JVM language written some Scala code and understand its fundementals familiar with SBT (like maven)
  • 3. About this talk is for "Impatient" help you to write Akka Code "right now" in Scala distinguish Actor model and Akka not teaching the partial functions and algebraic data types in Scala cover all aspects of Akka
  • 4. Agenda What makes us to consider Actor Model Understanding Actor model of programming Introducing to Akka Akka Actor model approach Setting up Writing Actors using Akka (with code examples) Moving forward (touchbase) Q&A
  • 5. What makes us to consider Actor Model Modern day programming need to process lot of data in terms of - volume - variety - velocity our code started to use multiple CPU cores within the machine or across a cluster
  • 6. What makes us to consider Actor Model (contd) Obvious option is to consider aysnc programming with "threads" (atleast in Java) programming for threads is a cumbersome requires a lot of boiler-plate code communicaiton between threads (with in and outside JVM) is tedious
  • 7. What makes us to consider Actor Model (contd) does this means the thread model is broken ?? No .. but it serves as a good foundation just that it need better async abstraction
  • 8. So how do we solve this ? for writing concurrent and distributed programs, we need threads to communicate easily "Actor Model" to the rescue
  • 9. What is an Actor this model prescribes an "Actor" backed by a thread model (by the underlying runtime or OS) Async abstraction can be expressed as an actor in the form of Class or function an Actor framework can create & manage actor clients can communicate only by passing messages (Async'ly) to the actor actors can also communicate between themselves
  • 10. What is an Actor unlike Thread, an Actor message driven responds to certain messages from other Actors (or non-actors) can handle only one message at any instant of time
  • 11. Actor model of programming (contd)
  • 12. Introducing Akka Scala/Java API whcih implements the Actor model provides a framework to create & manage actors , backed by JVM Thread model Akka provides a mailbox for each actor : in- memory queue to stage messages clients acan send messages either by ! send or ? ask pattern (more on that later) actor reveives messages and respond to clients Akka actors use pattern matching to hande messages
  • 14. Setting up sbt co-ordinates in build.sbt name := "hyscala-akka-intro-talk" version := "1.0" scalaVersion := "2.11.8" libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.4.14") open the project in your IDE to get started
  • 15. plain simple actor class PlainActor extends Actor { def receive: Receive = { case _ => } } actor which can respond to some messages: class PrimitiveHandlingActor extends Actor { def receive: Receive = { case "hello world" => println("""received hello world """) case 11 => println("received ") case _ => println("some other data type") } }
  • 16. simple shopping cart cart and order as two actors show case their interaction with simple messages covers actor to actor message passing
  • 17. Messages case class Item(name: String, quantity: Int, rate: Double) case object Done case class Order(item: List[Item])
  • 18. Cart Actor class CartActor extends Actor { val items = ListBuffer[Item]() def receive: Receive = { case item: Item => items.+=(item) // done with adding items to cart case Done => ??? } }
  • 19. Cart Actor - next version class CartActor(billingActor: ActorRef) extends Actor { ... case Done => billingActor ! Order(items.toList) items.clear() }
  • 20. Billing Actor class BilingActor extends Actor { def receive: Receive = { case order: Order => println(s"Here your bill ${Bill(order.items.foldLeft(0.0)((a } }
  • 21. all together .... ouput: Here your bill Bill(175.0) object AkkaIntroTalk extends App { val actorSystem = ActorSystem("actorsystem") val billingActor = actorSystem.actorOf(Props[BillingActor], val cartActor = actorSystem.actorOf(Props(classOf[CartAct cartActor ! Item("Apple", 3, 20.0) cartActor ! Item("Orange", 3, 15.0) cartActor ! Item("Butter", 1, 70.0) cartActor ! Done }
  • 22. Learning Akka Online Akka Docs Let it crash - blog Books Learning Akka Reactive Programming with Scala and Akka - (I've authored this book)
  • 23. Moving forward (touchbase) Actor heirarchy FSM Load Balacing Akka Clustering Akka HTTP
  • 25. Q&A