SlideShare a Scribd company logo
1 of 39
Reactive Java
Programming for the
Impatient
—
Mary Grygleski @mgrygles
IBM Developer Advocate
Java
mary.grygleski@ibm.com
Grant Steinfeld @gsteinfeld
IBM Developer Advocate Java &
Blockchain
Agenda
6:30 – 7pm Networking Food
7:00 – 8pm Talk and Demo
8:30 – Q&A + Networking
8:45 – Leave Venue/Doors close
IBM Developer Advocacy - North America East
What is Reactive?
IBM Developer Advocacy - North America East
Organizations working in disparate domains are
independently discovering patterns for building
software that look the same.
These systems are more robust, more resilient,
more flexible and better positioned to meet modern
demands. ... We call these Reactive Systems.
The React i ve
Mani f est o
Published on September 16 2014. (v2.0)
https://www.ReactiveManifesto.org/
Why Reactive?
IBM Developer Advocacy - North America East
Fast is not fast enough!
IBM Developer Advocacy - North America East
Evolving changes and demands in the Computing
Ecosystem
IBM Developer Advocacy - North America East
– Hardware Level
– Software System Level
– Software Application Level
– The impatient User
• “Instantaneous is not fast enough - if no response in <
2 seconds most users under 25 years old will leave the
website/app!”
What is Reactive?
IBM Developer Advocacy - North America East
IBM Developer Advocacy - North America East
Reactive Principles
Important distinctions…
Reactive Programming Functional Reactive
Programming
Reactive Systems and
Architecture
Event-Driven vs Message-Driven
IBM Developer Advocacy - North America East
“An Interesting Reactive
use case:
IBM Developer Advocacy - North America East
Menya Mushashi
Ramen shop in Tokyo
Slow down. Spend more time observing
Reactive Systems : Design Patterns
13
• State Management and Persistence
• Flow Control
• Message Flow
• Fault Tolerance and Recovery
• Replication
• Resource Management
Reactive Microservices vs Monoliths
Isolation of State, Space, Time, Failure
Circuit Breakers
Back –Pressure
High Availability
Eventual Consistency
Reactive Terminology
IBM Developer Advocacy - North America East
What about Microservices?
15
How are Microservices related to Reactive Programming, and
also Reactive Systems?
Rx Marble Diagram
16
Rx Marble Diagram: Map()
17
Observable.just(1, 2, 3)
.map(x -> 10 * x)
.subscribe(x -> Timber.d("item: " + x)));
Output:
item: 10
item: 20
item: 30
Source: https://rxmarbles.com
Reactive Patterns and
Terminologies
* Reactivity
* Events
* Streams
* Observables
DESIGN PATTERNS
Observer
Composite
Iterator
IBM Developer Advocacy - North America East
Reactive – Design Thinking
RxJava
* v1 (pre reactive streams specification) 2014
* v2 2016 (Flowable, with backpressure)
• Java implementation of ReactiveX (reactivex.io)
* Very popular, especially on Android.
•
* Also available in Javascript, .NET, Scala, Clojure, Swift
(and more!) with equivalent API.
IBM Developer Advocacy - North America East
4 Popular Reactive Tools
and Libraries
IBM Developer Advocacy - North America East
• RxJava
• Spring Reactor
• Akka
• Eclipse Vert.x
Fast is not fast
enough!
B
M
D
ev
el
o
p
er
A
dv
oc
ac
N
or
h
A
m
er
c
a
E
as
Code Examples
B
M
D
ev
el
o
p
er
A
dv
oc
ac
N
or
h
A
m
er
c
a
E
as
Simple Example: Hello World
IBM Developer Advocacy - North America East
import reactivex.io.*;
public static void hello(String[] args) {
Flowable.fromArray(args).subscribe(s -> System.out.println("Hello World :: " + s + "!"));
}
IBM Developer Advocacy - North America East
import io.reactivex.Observable;
import io.reactivex.functions.Consumer;
public class RxJavaObserverObservable
{
public static void main(String[] args)
{
Observable<String> observable = Observable.just("how", "to", "do", "in", "java");
Consumer<? super String> observer = System.out::println;
observable.subscribe(observer);
}
}
Key Design Pattern: Observer
Spring Reactor
IBM Developer Advocacy - North America East
Based on Project Reactor
Out of Pivotal Labs
Similar to RxJava2
Built for Java 8 ( concise )
Author: David Karnok
Karnok@akarnokd
User Reactor 3
allowed to use Java 8+,
use RxJava 2 if you are
stuck on Java 6+ or need
your functions to throw
checked exceptions
Why?
* Reactor Core
* Reactor Test
* Rector Extra
* Reactor Netty
* Reactor Adapter
* Reactor Kafka
* Reactor RabbitMQ
* Incubating reactive
streams foundation for
.Net, Javascript
Spring 5 Spring Web Reactive ( non-blocking web stack )
//Traditional Approach (Spring MVC):
@GetMapping("/traditional")
public List < Product > getAllProducts() {
List < Product > products = prodService.getProducts("traditional");
return products;
}
//Reactive Approach (Spring Web Reactive – Web Flux):
@GetMapping(value = "/reactive", .TEXT_EVENT_STREAM_VALUE)
public Flux < Product > getAll() {
Flux < Product > fluxProducts = prodService.getProductsStream("Flux");
return fluxProducts;
}
28
Quick comparison: RxJava vs Spring Reactor
Akka
* From LightBend. - IBM Partnership (June 2017)
https://www.lightbend.com/ibm-alliance
* Actor Model (from Erlang – Actor Programming Model in the 1980’s)
* Event-Driven
* Location Transparency
* Lightweight
* Resiliency/Recoverability – Supervisor capability
North America, East
package sample.hello;
public class Main {
public static void main(String[] args) {
akka.Main.main(new String[] { HelloWorld.class.getName() });
}
}
North America, East
31
package sample.hello;
import akka.actor.AbstractActor;
import akka.actor.ActorRef;
import akka.actor.Props;
import static sample.hello.Greeter.Msg;
public class HelloWorld extends AbstractActor {
@Override
public Receive createReceive() {
return receiveBuilder()
.matchEquals(Msg.DONE, m -> {
// when the greeter is done, stop this actor and with it the application
getContext().stop(self());
})
.build();
}
@Override
public void preStart() {
// create the greeter actor
final ActorRef greeter = getContext().actorOf(Props.create(Greeter.class), "greeter");
// tell it to perform the greeting
greeter.tell(Msg.GREET, self());
}
}
North America, East
32
package sample.hello;
import akka.actor.AbstractActor;
public class Greeter extends AbstractActor {
public static enum Msg {
GREET, DONE;
}
@Override
public Receive createReceive() {
return receiveBuilder()
.matchEquals(Msg.GREET, m -> {
System.out.println("Hello World!");
sender().tell(Msg.DONE, self());
})
.build();
}
}
North America, East
33
import akka.actor.{Actor, ActorSystem, Props}
//greet message
case class Greet(name: String)
//greeter Actor
class Greeter extends Actor {
def receive = {
case Greet(name) => println(s"Hello $name")
}
}
object HelloAkka extends App {
val system=ActorSystem("Intro-Akka")
val greeter=system.actorOf(Props[Greeter],"greeter")
greeter ! Greet("Akka")
}
North America, East
34
Vert.x
* From Eclipse
* A very flexible “polyglot” framework that interoperates with other frameworks and tools.
-> RxJava
-> Spring Reactor
-> Akka
-> not to mention the other non-Java frameworks and tools as well (JS, .Net…)
* Verticles – components that are being deployed and executed by Vert.x
-> event-driven
-> run only when they receive a message
* Vert.x event bus
* Not restrictively tied to any container – Vert.x libraries can be used with other libraries
North America, East
35
package io.vertx.example;
import io.vertx.core.Vertx;
public class HelloWorldEmbedded {
public static void main(String[] args) {
// Create an HTTP server which simply returns "Hello World!" to each request.
Vertx.vertx().createHttpServer().requestHandler(req -> req.response().end("Hello
World!")).listen(8080);
}
North America, East
Recap and Takeaways
IBM Developer Advocacy - North America East
• Reactive is an overloaded word in today’s market
• Not for the ”faint of heart” but for the determined
• Reactive programming is not the same as Functional
• Reactive programming or Reactive systems
• Benefits of being “Reactive” on the programming level
• Reactive systems and architecture bring “reactivity” to
another level
• Reactivity to this day has not been fully ready on the
database level, despite some significant efforts on the
database connectivity level
Thank You
IBM Developer Advocacy - North America East
twitter.com/mgrygles
twitter.com/gsteinfeld
github.com/mgrygles
github.com/grant-steinfeld
Resources
https://developer.ibm.com/technologies/reactive-
systems/
https://www.lightbend.com/ibm-alliancec
https://www.reactivemanifesto.org
https://www.reactivedesignpatterns.com
IBM Developer Advocacy - North America East
Check in periodically at https://developer.ibm.com/events/
Join us for more exciting
adventures in async.
meetups, workshops, coffee
and code sessions.
IBM Developer Advocacy - North America East

More Related Content

What's hot

A Tour of the Modern Java Platform
A Tour of the Modern Java PlatformA Tour of the Modern Java Platform
A Tour of the Modern Java PlatformVMware Tanzu
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMJimit Shah
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5Gal Marder
 
How Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemHow Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemKonrad Malawski
 
Reactive integrations with Akka Streams
Reactive integrations with Akka StreamsReactive integrations with Akka Streams
Reactive integrations with Akka StreamsKonrad Malawski
 
Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019graemerocher
 
Introduction to Micronaut at Oracle CodeOne 2018
Introduction to Micronaut at Oracle CodeOne 2018Introduction to Micronaut at Oracle CodeOne 2018
Introduction to Micronaut at Oracle CodeOne 2018graemerocher
 
Reactive Streams: Handling Data-Flow the Reactive Way
Reactive Streams: Handling Data-Flow the Reactive WayReactive Streams: Handling Data-Flow the Reactive Way
Reactive Streams: Handling Data-Flow the Reactive WayRoland Kuhn
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Konrad Malawski
 
Reactive Jersey Client
Reactive Jersey ClientReactive Jersey Client
Reactive Jersey ClientMichal Gajdos
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesLauren Yew
 
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...VMware Tanzu
 
Advanced #6 clean architecture
Advanced #6  clean architectureAdvanced #6  clean architecture
Advanced #6 clean architectureVitali Pekelis
 
Interactive Kafka Streams
Interactive Kafka StreamsInteractive Kafka Streams
Interactive Kafka Streamsconfluent
 
Micronaut Deep Dive - Devoxx Belgium 2019
Micronaut Deep Dive - Devoxx Belgium 2019Micronaut Deep Dive - Devoxx Belgium 2019
Micronaut Deep Dive - Devoxx Belgium 2019graemerocher
 

What's hot (20)

A Tour of the Modern Java Platform
A Tour of the Modern Java PlatformA Tour of the Modern Java Platform
A Tour of the Modern Java Platform
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
 
What’s expected in Spring 5
What’s expected in Spring 5What’s expected in Spring 5
What’s expected in Spring 5
 
How Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM EcosystemHow Reactive Streams & Akka Streams change the JVM Ecosystem
How Reactive Streams & Akka Streams change the JVM Ecosystem
 
Javantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin ToshevJavantura v4 - JVM++ The GraalVM - Martin Toshev
Javantura v4 - JVM++ The GraalVM - Martin Toshev
 
Reactive integrations with Akka Streams
Reactive integrations with Akka StreamsReactive integrations with Akka Streams
Reactive integrations with Akka Streams
 
React + Redux for Web Developers
React + Redux for Web DevelopersReact + Redux for Web Developers
React + Redux for Web Developers
 
Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019Introduction to Micronaut - JBCNConf 2019
Introduction to Micronaut - JBCNConf 2019
 
Introduction to Micronaut at Oracle CodeOne 2018
Introduction to Micronaut at Oracle CodeOne 2018Introduction to Micronaut at Oracle CodeOne 2018
Introduction to Micronaut at Oracle CodeOne 2018
 
Reactive Streams: Handling Data-Flow the Reactive Way
Reactive Streams: Handling Data-Flow the Reactive WayReactive Streams: Handling Data-Flow the Reactive Way
Reactive Streams: Handling Data-Flow the Reactive Way
 
Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016Akka Streams in Action @ ScalaDays Berlin 2016
Akka Streams in Action @ ScalaDays Berlin 2016
 
Reactive Jersey Client
Reactive Jersey ClientReactive Jersey Client
Reactive Jersey Client
 
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
Javantura v4 - Java and lambdas and streams - are they better than for loops ...Javantura v4 - Java and lambdas and streams - are they better than for loops ...
Javantura v4 - Java and lambdas and streams - are they better than for loops ...
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
 
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
The Making of the Oracle R2DBC Driver and How to Take Your Code from Synchron...
 
Advanced #6 clean architecture
Advanced #6  clean architectureAdvanced #6  clean architecture
Advanced #6 clean architecture
 
Azkaban
AzkabanAzkaban
Azkaban
 
Task flow
Task flowTask flow
Task flow
 
Interactive Kafka Streams
Interactive Kafka StreamsInteractive Kafka Streams
Interactive Kafka Streams
 
Micronaut Deep Dive - Devoxx Belgium 2019
Micronaut Deep Dive - Devoxx Belgium 2019Micronaut Deep Dive - Devoxx Belgium 2019
Micronaut Deep Dive - Devoxx Belgium 2019
 

Similar to Reactive java programming for the impatient

IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016Trayan Iliev
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorVMware Tanzu
 
IBM InterConnect: Java vs JavaScript for Enterprise WebApps
IBM InterConnect: Java vs JavaScript for Enterprise WebAppsIBM InterConnect: Java vs JavaScript for Enterprise WebApps
IBM InterConnect: Java vs JavaScript for Enterprise WebAppsChris Bailey
 
Reactive in Android and Beyond Rx
Reactive in Android and Beyond RxReactive in Android and Beyond Rx
Reactive in Android and Beyond RxFabio Tiriticco
 
NGRX Apps in Depth
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in DepthTrayan Iliev
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptJohn Stevenson
 
Don't Wait! Develop responsive applications with Java EE7 instead
Don't Wait! Develop responsive applications with Java EE7 insteadDon't Wait! Develop responsive applications with Java EE7 instead
Don't Wait! Develop responsive applications with Java EE7 insteadErin Schnabel
 
Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018Trayan Iliev
 
Microservices with Spring 5 Webflux - jProfessionals
Microservices  with Spring 5 Webflux - jProfessionalsMicroservices  with Spring 5 Webflux - jProfessionals
Microservices with Spring 5 Webflux - jProfessionalsTrayan Iliev
 
Isomorphic JavaScript with Nashorn
Isomorphic JavaScript with NashornIsomorphic JavaScript with Nashorn
Isomorphic JavaScript with NashornMaxime Najim
 
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016Trayan Iliev
 
Reactive Microservice And Spring5
Reactive Microservice And Spring5Reactive Microservice And Spring5
Reactive Microservice And Spring5Jay Lee
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Zach Lendon
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementZach Lendon
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examplesPeter Lawrey
 
Javaforum 20110915
Javaforum 20110915Javaforum 20110915
Javaforum 20110915Squeed
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...Codemotion
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
An evening with React Native
An evening with React NativeAn evening with React Native
An evening with React NativeMike Melusky
 
Reactive Java Robotics and IoT 2016
Reactive Java Robotics and IoT 2016Reactive Java Robotics and IoT 2016
Reactive Java Robotics and IoT 2016ilievt
 

Similar to Reactive java programming for the impatient (20)

IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
 
IBM InterConnect: Java vs JavaScript for Enterprise WebApps
IBM InterConnect: Java vs JavaScript for Enterprise WebAppsIBM InterConnect: Java vs JavaScript for Enterprise WebApps
IBM InterConnect: Java vs JavaScript for Enterprise WebApps
 
Reactive in Android and Beyond Rx
Reactive in Android and Beyond RxReactive in Android and Beyond Rx
Reactive in Android and Beyond Rx
 
NGRX Apps in Depth
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in Depth
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
Don't Wait! Develop responsive applications with Java EE7 instead
Don't Wait! Develop responsive applications with Java EE7 insteadDon't Wait! Develop responsive applications with Java EE7 instead
Don't Wait! Develop responsive applications with Java EE7 instead
 
Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018Spring 5 Webflux - Advances in Java 2018
Spring 5 Webflux - Advances in Java 2018
 
Microservices with Spring 5 Webflux - jProfessionals
Microservices  with Spring 5 Webflux - jProfessionalsMicroservices  with Spring 5 Webflux - jProfessionals
Microservices with Spring 5 Webflux - jProfessionals
 
Isomorphic JavaScript with Nashorn
Isomorphic JavaScript with NashornIsomorphic JavaScript with Nashorn
Isomorphic JavaScript with Nashorn
 
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
 
Reactive Microservice And Spring5
Reactive Microservice And Spring5Reactive Microservice And Spring5
Reactive Microservice And Spring5
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Javaforum 20110915
Javaforum 20110915Javaforum 20110915
Javaforum 20110915
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
An evening with React Native
An evening with React NativeAn evening with React Native
An evening with React Native
 
Reactive Java Robotics and IoT 2016
Reactive Java Robotics and IoT 2016Reactive Java Robotics and IoT 2016
Reactive Java Robotics and IoT 2016
 

Recently uploaded

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Recently uploaded (20)

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

Reactive java programming for the impatient

  • 1. Reactive Java Programming for the Impatient — Mary Grygleski @mgrygles IBM Developer Advocate Java mary.grygleski@ibm.com Grant Steinfeld @gsteinfeld IBM Developer Advocate Java & Blockchain
  • 2. Agenda 6:30 – 7pm Networking Food 7:00 – 8pm Talk and Demo 8:30 – Q&A + Networking 8:45 – Leave Venue/Doors close IBM Developer Advocacy - North America East
  • 3. What is Reactive? IBM Developer Advocacy - North America East Organizations working in disparate domains are independently discovering patterns for building software that look the same. These systems are more robust, more resilient, more flexible and better positioned to meet modern demands. ... We call these Reactive Systems. The React i ve Mani f est o Published on September 16 2014. (v2.0) https://www.ReactiveManifesto.org/
  • 4. Why Reactive? IBM Developer Advocacy - North America East
  • 5. Fast is not fast enough! IBM Developer Advocacy - North America East
  • 6. Evolving changes and demands in the Computing Ecosystem IBM Developer Advocacy - North America East – Hardware Level – Software System Level – Software Application Level – The impatient User • “Instantaneous is not fast enough - if no response in < 2 seconds most users under 25 years old will leave the website/app!”
  • 7. What is Reactive? IBM Developer Advocacy - North America East
  • 8. IBM Developer Advocacy - North America East Reactive Principles
  • 9. Important distinctions… Reactive Programming Functional Reactive Programming Reactive Systems and Architecture
  • 10. Event-Driven vs Message-Driven IBM Developer Advocacy - North America East
  • 11. “An Interesting Reactive use case: IBM Developer Advocacy - North America East Menya Mushashi Ramen shop in Tokyo
  • 12. Slow down. Spend more time observing
  • 13. Reactive Systems : Design Patterns 13 • State Management and Persistence • Flow Control • Message Flow • Fault Tolerance and Recovery • Replication • Resource Management
  • 14. Reactive Microservices vs Monoliths Isolation of State, Space, Time, Failure Circuit Breakers Back –Pressure High Availability Eventual Consistency Reactive Terminology IBM Developer Advocacy - North America East
  • 15. What about Microservices? 15 How are Microservices related to Reactive Programming, and also Reactive Systems?
  • 17. Rx Marble Diagram: Map() 17 Observable.just(1, 2, 3) .map(x -> 10 * x) .subscribe(x -> Timber.d("item: " + x))); Output: item: 10 item: 20 item: 30 Source: https://rxmarbles.com
  • 18. Reactive Patterns and Terminologies * Reactivity * Events * Streams * Observables DESIGN PATTERNS Observer Composite Iterator IBM Developer Advocacy - North America East
  • 20. RxJava * v1 (pre reactive streams specification) 2014 * v2 2016 (Flowable, with backpressure) • Java implementation of ReactiveX (reactivex.io) * Very popular, especially on Android. • * Also available in Javascript, .NET, Scala, Clojure, Swift (and more!) with equivalent API. IBM Developer Advocacy - North America East
  • 21. 4 Popular Reactive Tools and Libraries IBM Developer Advocacy - North America East • RxJava • Spring Reactor • Akka • Eclipse Vert.x
  • 22. Fast is not fast enough! B M D ev el o p er A dv oc ac N or h A m er c a E as
  • 24. Simple Example: Hello World IBM Developer Advocacy - North America East import reactivex.io.*; public static void hello(String[] args) { Flowable.fromArray(args).subscribe(s -> System.out.println("Hello World :: " + s + "!")); }
  • 25. IBM Developer Advocacy - North America East import io.reactivex.Observable; import io.reactivex.functions.Consumer; public class RxJavaObserverObservable { public static void main(String[] args) { Observable<String> observable = Observable.just("how", "to", "do", "in", "java"); Consumer<? super String> observer = System.out::println; observable.subscribe(observer); } } Key Design Pattern: Observer
  • 26. Spring Reactor IBM Developer Advocacy - North America East Based on Project Reactor Out of Pivotal Labs Similar to RxJava2 Built for Java 8 ( concise ) Author: David Karnok Karnok@akarnokd User Reactor 3 allowed to use Java 8+, use RxJava 2 if you are stuck on Java 6+ or need your functions to throw checked exceptions Why? * Reactor Core * Reactor Test * Rector Extra * Reactor Netty * Reactor Adapter * Reactor Kafka * Reactor RabbitMQ * Incubating reactive streams foundation for .Net, Javascript
  • 27. Spring 5 Spring Web Reactive ( non-blocking web stack ) //Traditional Approach (Spring MVC): @GetMapping("/traditional") public List < Product > getAllProducts() { List < Product > products = prodService.getProducts("traditional"); return products; } //Reactive Approach (Spring Web Reactive – Web Flux): @GetMapping(value = "/reactive", .TEXT_EVENT_STREAM_VALUE) public Flux < Product > getAll() { Flux < Product > fluxProducts = prodService.getProductsStream("Flux"); return fluxProducts; }
  • 28. 28 Quick comparison: RxJava vs Spring Reactor
  • 29. Akka * From LightBend. - IBM Partnership (June 2017) https://www.lightbend.com/ibm-alliance * Actor Model (from Erlang – Actor Programming Model in the 1980’s) * Event-Driven * Location Transparency * Lightweight * Resiliency/Recoverability – Supervisor capability North America, East
  • 30. package sample.hello; public class Main { public static void main(String[] args) { akka.Main.main(new String[] { HelloWorld.class.getName() }); } } North America, East
  • 31. 31 package sample.hello; import akka.actor.AbstractActor; import akka.actor.ActorRef; import akka.actor.Props; import static sample.hello.Greeter.Msg; public class HelloWorld extends AbstractActor { @Override public Receive createReceive() { return receiveBuilder() .matchEquals(Msg.DONE, m -> { // when the greeter is done, stop this actor and with it the application getContext().stop(self()); }) .build(); } @Override public void preStart() { // create the greeter actor final ActorRef greeter = getContext().actorOf(Props.create(Greeter.class), "greeter"); // tell it to perform the greeting greeter.tell(Msg.GREET, self()); } } North America, East
  • 32. 32 package sample.hello; import akka.actor.AbstractActor; public class Greeter extends AbstractActor { public static enum Msg { GREET, DONE; } @Override public Receive createReceive() { return receiveBuilder() .matchEquals(Msg.GREET, m -> { System.out.println("Hello World!"); sender().tell(Msg.DONE, self()); }) .build(); } } North America, East
  • 33. 33 import akka.actor.{Actor, ActorSystem, Props} //greet message case class Greet(name: String) //greeter Actor class Greeter extends Actor { def receive = { case Greet(name) => println(s"Hello $name") } } object HelloAkka extends App { val system=ActorSystem("Intro-Akka") val greeter=system.actorOf(Props[Greeter],"greeter") greeter ! Greet("Akka") } North America, East
  • 34. 34 Vert.x * From Eclipse * A very flexible “polyglot” framework that interoperates with other frameworks and tools. -> RxJava -> Spring Reactor -> Akka -> not to mention the other non-Java frameworks and tools as well (JS, .Net…) * Verticles – components that are being deployed and executed by Vert.x -> event-driven -> run only when they receive a message * Vert.x event bus * Not restrictively tied to any container – Vert.x libraries can be used with other libraries North America, East
  • 35. 35 package io.vertx.example; import io.vertx.core.Vertx; public class HelloWorldEmbedded { public static void main(String[] args) { // Create an HTTP server which simply returns "Hello World!" to each request. Vertx.vertx().createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080); } North America, East
  • 36. Recap and Takeaways IBM Developer Advocacy - North America East • Reactive is an overloaded word in today’s market • Not for the ”faint of heart” but for the determined • Reactive programming is not the same as Functional • Reactive programming or Reactive systems • Benefits of being “Reactive” on the programming level • Reactive systems and architecture bring “reactivity” to another level • Reactivity to this day has not been fully ready on the database level, despite some significant efforts on the database connectivity level
  • 37. Thank You IBM Developer Advocacy - North America East twitter.com/mgrygles twitter.com/gsteinfeld github.com/mgrygles github.com/grant-steinfeld
  • 39. Check in periodically at https://developer.ibm.com/events/ Join us for more exciting adventures in async. meetups, workshops, coffee and code sessions. IBM Developer Advocacy - North America East

Editor's Notes

  1. Asynchronous Backends
  2. State management and persistence patterns Domain object Sharding Event sourcing Event stream Flow control patterns Pull Managed queue Drop Throttling Message flow patterns Request–response Self-contained message Ask pattern Forward Flow Aggregator Saga Business Handshake Fault tolerance and recovery patterns Simple Component Error Kernel Let-it-crash Circuit Breaker Replication patterns Active–passive Multiple-master Consensus-based Conflict detection and resolution Conflict-free replicated data types Active–active Resource management patterns Resource encapsulation Resource loan Complex command Resource pool Managed blocking