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)

PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Modernizing your data center with Dell and AMD
PPT
Teaching material agriculture food technology
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Machine learning based COVID-19 study performance prediction
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
Understanding_Digital_Forensics_Presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Electronic commerce courselecture one. Pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
cuic standard and advanced reporting.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
Modernizing your data center with Dell and AMD
Teaching material agriculture food technology
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Machine learning based COVID-19 study performance prediction
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
The Rise and Fall of 3GPP – Time for a Sabbatical?
MYSQL Presentation for SQL database connectivity
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation_ Review paper, used for researhc scholars
20250228 LYD VKU AI Blended-Learning.pptx

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