Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Reactive Programming
using RxJava & Akka Actors
Thomas Lockney (@tlockney)
PDXScala
June 14, 2014
What is reactive
programming?
Reactive programming is…
● A programming paradigm
● About data-flow
● Not really anything new
Reactive programming is...
● Event-driven
● Scalable
● Resilient
● Responsive
(the definition via the manifesto, anyway)
Reorganizing our thoughts a bit...
● Think in terms of discrete events
● Code in terms of behaviors
○ reacting to events
●...
A brief digression...
Amdahl’s law (paraphrased):
The maximum increase in speed of a program
is limited by the sequential ...
A brief digression...
Amdahl’s law (paraphrased):
If you have a program that runs for 4 hours, but
1 hour of runtime is ne...
Amdahl’s law
The thing about Amdahl’s law
This is death by a thousand cuts.
Every line of code is subject to this rule!
Some principles...
● Keep your data immutable
● Share nothing
● Blocking is bad!
Another brief digression...
● Immutable data structures
● Referential transparency
● First-class functions
… this gives you ...
Once you have:
Functional Programming
well...
Functional Programming
in the small
RxJava
“a library for composing asynchronous and
event-based programs using observable
sequences for the Java VM”
My translation:
RxJava
A library for composing behaviors
applied to event streams.
note: when I say behaviors, think
refer...
Marble Diagrams
Observable
● The “dual” of Iterable
● Or an Observer for sequences
● Somewhat similar to a Future
○ but, again, supports s...
Observable
Basic mechanics
● onNext()
● onError()
● onComplete()
Functional Composition
● map()
● flatMap()
● filter()
map()
flatMap()
filter()
Creating Observables
● Observable.from(...), Observable.just(...),
Observable.range(...), etc.
● Implement the Observable ...
Observer & Subscriber
Observer
● interface for handling Observables onNext,
onError, onComplete
Subscriber
● represents a ...
Demo time!
RxJava is Reactive
● event-based (data-flows)
● scalable*
● resilient* (???)
● responsive* (???)
* - requires some additio...
Akka
& the actor model
Actors (the Actor model)
Defined by three traits
● a behavior (reacts to events)
● an state model
● send/receive (immutabl...
Actors
● messages are processed sequentially
● multiple actors can be working at the same
time
● actors are not threads
● ...
Actor System
● actors interact
● actors exist together within an actor system
● the system defines the outermost bounds
Akka
● Scala-based actor model toolkit
● Provides a lot of extras
● We won’t be talking about those
Akka
● Supervisors
○ provide exception handling
○ “let it crash”
○ orthogonal to actor behavior
● Location transparency
○ ...
Akka
● Mailboxes
● Routing
○ e.g., round-robin, smallest mailbox, etc.
● Dispatching
○ essentially how to allocate thread ...
Demo time!
Akka is Reactive
● event-based
● resilient/fault-tolerant
● easily scalable*
● responsive*
* - requires some additional wo...
Reactive Streams
Reactive Streams
… I wish I had time … ;~)
Prochain SlideShare
Chargement dans…5
×

sur

Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 1 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 2 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 3 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 4 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 5 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 6 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 7 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 8 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 9 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 10 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 11 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 12 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 13 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 14 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 15 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 16 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 17 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 18 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 19 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 20 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 21 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 22 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 23 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 24 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 25 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 26 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 27 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 28 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 29 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 30 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 31 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 32 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 33 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 34 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 35 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 36 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 37 Reactive programming   using rx java & akka actors - pdx-scala - june 2014 Slide 38
Prochain SlideShare
Reactive Java (GeeCON 2014)
Suivant
Télécharger pour lire hors ligne et voir en mode plein écran

33 j’aime

Partager

Télécharger pour lire hors ligne

Reactive programming using rx java & akka actors - pdx-scala - june 2014

Télécharger pour lire hors ligne

Reactive programming using rx java & akka actors - pdx-scala - june 2014

  1. 1. Reactive Programming using RxJava & Akka Actors Thomas Lockney (@tlockney) PDXScala June 14, 2014
  2. 2. What is reactive programming?
  3. 3. Reactive programming is… ● A programming paradigm ● About data-flow ● Not really anything new
  4. 4. Reactive programming is... ● Event-driven ● Scalable ● Resilient ● Responsive (the definition via the manifesto, anyway)
  5. 5. Reorganizing our thoughts a bit... ● Think in terms of discrete events ● Code in terms of behaviors ○ reacting to events ● The system state changes over time based on the flow of events
  6. 6. A brief digression... Amdahl’s law (paraphrased): The maximum increase in speed of a program is limited by the sequential portions of the code.
  7. 7. A brief digression... Amdahl’s law (paraphrased): If you have a program that runs for 4 hours, but 1 hour of runtime is necessarily serial, your program will have at most a 4x speedup with parallelization.
  8. 8. Amdahl’s law
  9. 9. The thing about Amdahl’s law This is death by a thousand cuts. Every line of code is subject to this rule!
  10. 10. Some principles... ● Keep your data immutable ● Share nothing ● Blocking is bad!
  11. 11. Another brief digression...
  12. 12. ● Immutable data structures ● Referential transparency ● First-class functions … this gives you ... Once you have:
  13. 13. Functional Programming
  14. 14. well... Functional Programming in the small
  15. 15. RxJava “a library for composing asynchronous and event-based programs using observable sequences for the Java VM”
  16. 16. My translation: RxJava A library for composing behaviors applied to event streams. note: when I say behaviors, think referentially-transparent functions.
  17. 17. Marble Diagrams
  18. 18. Observable ● The “dual” of Iterable ● Or an Observer for sequences ● Somewhat similar to a Future ○ but, again, supports sequences
  19. 19. Observable Basic mechanics ● onNext() ● onError() ● onComplete()
  20. 20. Functional Composition ● map() ● flatMap() ● filter()
  21. 21. map()
  22. 22. flatMap()
  23. 23. filter()
  24. 24. Creating Observables ● Observable.from(...), Observable.just(...), Observable.range(...), etc. ● Implement the Observable interface ○ explicit calls to onNext(), onError(), onComplete()
  25. 25. Observer & Subscriber Observer ● interface for handling Observables onNext, onError, onComplete Subscriber ● represents a subscription to an observable
  26. 26. Demo time!
  27. 27. RxJava is Reactive ● event-based (data-flows) ● scalable* ● resilient* (???) ● responsive* (???) * - requires some additional work on your end ??? - the story here is not entirely clear or potentially even available in current releases
  28. 28. Akka & the actor model
  29. 29. Actors (the Actor model) Defined by three traits ● a behavior (reacts to events) ● an state model ● send/receive (immutable) messages
  30. 30. Actors ● messages are processed sequentially ● multiple actors can be working at the same time ● actors are not threads ● an actor can block (but should avoid it) ● no shared state
  31. 31. Actor System ● actors interact ● actors exist together within an actor system ● the system defines the outermost bounds
  32. 32. Akka ● Scala-based actor model toolkit ● Provides a lot of extras ● We won’t be talking about those
  33. 33. Akka ● Supervisors ○ provide exception handling ○ “let it crash” ○ orthogonal to actor behavior ● Location transparency ○ abstracts the idea of “where” an actor lives
  34. 34. Akka ● Mailboxes ● Routing ○ e.g., round-robin, smallest mailbox, etc. ● Dispatching ○ essentially how to allocate thread resources
  35. 35. Demo time!
  36. 36. Akka is Reactive ● event-based ● resilient/fault-tolerant ● easily scalable* ● responsive* * - requires some additional work on your end
  37. 37. Reactive Streams
  38. 38. Reactive Streams … I wish I had time … ;~)
  • changhwanhan1

    Nov. 18, 2016
  • LoveHasija

    Sep. 28, 2016
  • vovche

    Nov. 17, 2015
  • DanielZhelyazkov1

    Nov. 2, 2015
  • alexeyshockov

    Oct. 15, 2015
  • ismailover

    Sep. 28, 2015
  • tvhung

    Sep. 24, 2015
  • BerndGtz

    Sep. 14, 2015
  • ClumsyShark

    Aug. 9, 2015
  • ziyasal

    Jul. 13, 2015
  • DejanIli

    Jun. 26, 2015
  • AlbertSerrallRos

    May. 12, 2015
  • yth1

    May. 10, 2015
  • mohanmca

    May. 5, 2015
  • kwangyongkim

    Apr. 21, 2015
  • MartinWeidner

    Apr. 6, 2015
  • unizune

    Feb. 22, 2015
  • joobn

    Feb. 13, 2015
  • tantrieuf31

    Feb. 5, 2015
  • bunkertor

    Feb. 5, 2015

Vues

Nombre de vues

8 970

Sur Slideshare

0

À partir des intégrations

0

Nombre d'intégrations

280

Actions

Téléchargements

183

Partages

0

Commentaires

0

Mentions J'aime

33

×