SlideShare a Scribd company logo
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
● The system state changes over time based
on the flow of events
A brief digression...
Amdahl’s law (paraphrased):
The maximum increase in speed of a program
is limited by the sequential portions of the code.
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.
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
referentially-transparent functions.
Marble Diagrams
Observable
● The “dual” of Iterable
● Or an Observer for sequences
● Somewhat similar to a Future
○ but, again, supports sequences
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 interface
○ explicit calls to onNext(), onError(), onComplete()
Observer & Subscriber
Observer
● interface for handling Observables onNext,
onError, onComplete
Subscriber
● represents a subscription to an observable
Demo time!
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
Akka
& the actor model
Actors (the Actor model)
Defined by three traits
● a behavior (reacts to events)
● an state model
● send/receive (immutable) messages
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
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
○ abstracts the idea of “where” an actor lives
Akka
● Mailboxes
● Routing
○ e.g., round-robin, smallest mailbox, etc.
● Dispatching
○ essentially how to allocate thread resources
Demo time!
Akka is Reactive
● event-based
● resilient/fault-tolerant
● easily scalable*
● responsive*
* - requires some additional work on your end
Reactive Streams
Reactive Streams
… I wish I had time … ;~)

More Related Content

PPTX
Intro to Functional Programming with RxJava
PDF
Streams, Streams Everywhere! An Introduction to Rx
PDF
Reactive programming with Rxjava
PDF
RxJava - introduction & design
PPTX
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
PDF
Reactive programming with RxJava
PPTX
Reactive Programming and RxJS
PDF
Building Scalable Stateless Applications with RxJava
Intro to Functional Programming with RxJava
Streams, Streams Everywhere! An Introduction to Rx
Reactive programming with Rxjava
RxJava - introduction & design
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
Reactive programming with RxJava
Reactive Programming and RxJS
Building Scalable Stateless Applications with RxJava

What's hot (20)

PDF
Practical RxJava for Android
PDF
rx-java-presentation
PPTX
Introduction to Reactive programming
PPTX
Reactive Extensions for JavaScript
PPTX
Top 10 RxJs Operators in Angular
PPTX
Reactive Programming in Java 8 with Rx-Java
PDF
RxJava@Android
PDF
Journey into Reactive Streams and Akka Streams
PDF
Effective java item 80 and 81
PDF
Rxjava 介紹與 Android 中的 RxJava
PPTX
RxJS and Reactive Programming - Modern Web UI - May 2015
PPTX
Till Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
PDF
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
PDF
RxJS - The Reactive Extensions for JavaScript
PDF
Load test REST APIs using gatling
PPTX
Flink Forward SF 2017: Eron Wright - Introducing Flink Tensorflow
PDF
Flink Forward SF 2017: Dean Wampler - Streaming Deep Learning Scenarios with...
PDF
RxJava 2.0 介紹
PPTX
Stream processing from single node to a cluster
PDF
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Practical RxJava for Android
rx-java-presentation
Introduction to Reactive programming
Reactive Extensions for JavaScript
Top 10 RxJs Operators in Angular
Reactive Programming in Java 8 with Rx-Java
RxJava@Android
Journey into Reactive Streams and Akka Streams
Effective java item 80 and 81
Rxjava 介紹與 Android 中的 RxJava
RxJS and Reactive Programming - Modern Web UI - May 2015
Till Rohrmann – Fault Tolerance and Job Recovery in Apache Flink
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
RxJS - The Reactive Extensions for JavaScript
Load test REST APIs using gatling
Flink Forward SF 2017: Eron Wright - Introducing Flink Tensorflow
Flink Forward SF 2017: Dean Wampler - Streaming Deep Learning Scenarios with...
RxJava 2.0 介紹
Stream processing from single node to a cluster
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Ad

Viewers also liked (10)

PPTX
Reactive Java (GeeCON 2014)
PDF
Know your platform. 7 things every scala developer should know about jvm
PDF
Take a Look at Akka+Java (English version)
PPTX
Scala Programming for Semantic Web Developers ESWC Semdev2015
PPTX
Introduction to Akka - Atlanta Java Users Group
PDF
Reactive Programming for a demanding world: building event-driven and respons...
PPTX
Akka Actor presentation
PPTX
RuntimeUnitTestToolkit for Unity(English)
PPTX
RDF Stream Processing Tutorial: RSP implementations
PDF
What is tackled in the Java EE Security API (Java EE 8)
Reactive Java (GeeCON 2014)
Know your platform. 7 things every scala developer should know about jvm
Take a Look at Akka+Java (English version)
Scala Programming for Semantic Web Developers ESWC Semdev2015
Introduction to Akka - Atlanta Java Users Group
Reactive Programming for a demanding world: building event-driven and respons...
Akka Actor presentation
RuntimeUnitTestToolkit for Unity(English)
RDF Stream Processing Tutorial: RSP implementations
What is tackled in the Java EE Security API (Java EE 8)
Ad

Similar to Reactive programming using rx java & akka actors - pdx-scala - june 2014 (20)

PDF
Reactive java - Reactive Programming + RxJava
PDF
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
PPTX
PDF
Reactive programming
PPTX
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
PPTX
Reactiveness All The Way - SW Architecture 2015 Conference
PDF
Rx java workshop
PPTX
Introduction to RxJava on Android
PPTX
Reactive Programming with RxJava
PDF
The Mayans Lost Guide to RxJava on Android
PDF
Intro to Rx Java
PDF
Introduction to reactive programming
PPTX
RxJava 2 Reactive extensions for the JVM
PPT
Reactive programming with examples
PDF
I have a stream - Insights in Reactive Programming - Jan Carsten Lohmuller - ...
PDF
An Introduction to Reactive Application, Reactive Streams, and options for JVM
PDF
Reactive Functional Programming with Java 8 on Android N
PDF
A Quick Intro to ReactiveX
PDF
My Gentle Introduction to RxJS
PPTX
Reactive programming
Reactive java - Reactive Programming + RxJava
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
Reactive programming
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
Reactiveness All The Way - SW Architecture 2015 Conference
Rx java workshop
Introduction to RxJava on Android
Reactive Programming with RxJava
The Mayans Lost Guide to RxJava on Android
Intro to Rx Java
Introduction to reactive programming
RxJava 2 Reactive extensions for the JVM
Reactive programming with examples
I have a stream - Insights in Reactive Programming - Jan Carsten Lohmuller - ...
An Introduction to Reactive Application, Reactive Streams, and options for JVM
Reactive Functional Programming with Java 8 on Android N
A Quick Intro to ReactiveX
My Gentle Introduction to RxJS
Reactive programming

Recently uploaded (20)

PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Advanced IT Governance
PDF
Chapter 2 Digital Image Fundamentals.pdf
PPT
Teaching material agriculture food technology
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
cuic standard and advanced reporting.pdf
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
Modernizing your data center with Dell and AMD
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
Diabetes mellitus diagnosis method based random forest with bat algorithm
MYSQL Presentation for SQL database connectivity
Spectral efficient network and resource selection model in 5G networks
“AI and Expert System Decision Support & Business Intelligence Systems”
Understanding_Digital_Forensics_Presentation.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
GamePlan Trading System Review: Professional Trader's Honest Take
Review of recent advances in non-invasive hemoglobin estimation
Advanced IT Governance
Chapter 2 Digital Image Fundamentals.pdf
Teaching material agriculture food technology
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Chapter 3 Spatial Domain Image Processing.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Monthly Chronicles - July 2025
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
cuic standard and advanced reporting.pdf
Sensors and Actuators in IoT Systems using pdf
Modernizing your data center with Dell and AMD

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