SlideShare ist ein Scribd-Unternehmen logo
1 von 30
© 2013 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Reactor: A Foundation for Reactive
FastData Applications on the JVM
Jon Brisbin – @j_brisbin
Stephane Maldini – @smaldini
The Spring IO Directory
Reactor – Housekeeping
● Tweet questions during the presentation
– @ProjectReactor
– @j_brisbin
– @smaldini
● Stop us anywhere if you have a question
– There are no stupid questions, only stupid answers!
Reactor – What is it?
● Reactor is a foundational library
– Plays in grey area between user-level and lower-level
abstractions
– Components and application cores can be built on
Reactor
– Drivers, servers, data integration libraries, domain
integration libraries, Evented architectures
Reactor – What is it?
● Reactor is a distillation of other libraries and best-practices
– Elements of other patterns and libraries surface throughout
Reactor's abstractions
http://stackoverflow.com/questions/16595393/akka-or-reactor
Reactor – What can I build with it?
● Reactor applications are reactive
– Reactive Extensions in .NET
– Netflix RxJava
– Observer pattern
● Reactor applications route events based on a Selector
– Like a routing topic, but can be any object
– Regex, URI template, Class.isAssingableFrom, custom
logic
Reactor – Landscape
Reactor – What does it look like?
Environment env = new Environment();
Reactor reactor = Reactors.reactor()
.env(env)
.dispatcher(RING_BUFFER)
.get();
reactor.on($(“topic”), (Event<String> ev) → {
System.out.println(“Hello “ + ev.getData());
});
reactor.notify(“topic”, Event.wrap(“John Doe”));
Reactor – Selectors
● Selectors are the left-hand side of an equality comparison
– A Selector can be created from any object using $(obj)
(or the long form: Selectors.object(obj))
– A Selector can extract data from the matched key
– Predicate<T> Selectors can be created to match on
domain-specific criteria like header values
Reactor – Selectors
● A RegexSelector will match a String by executing the regex
over it
– R(“some.(.*)”)
– Selectors.regex(“some.(.*)”)
reactor.on(R(“some.(.+)”), (Event<String> ev) → {
// s will be 'topic'
String s = ev.getHeaders().get(“group1”);
});
reactor.notify(“some.topic”, Event.wrap(“John Doe”));
Reactor – Selectors
● A UriTemplateSelector will match a String by extracting bits
from a URI
– U(“/some/{path}”)
– Selectors.uri(“/some/{path}”)
reactor.on(U(“/some/{topic}”), (Event<String> ev) → {
// s will be 'topic'
String s = ev.getHeaders().get(“topic”);
});
reactor.notify(“/some/topic”, Event.wrap(“John Doe”));
Reactor – Consumer, Function, Supplier, Predicate
public interface Consumer<T> {
void accept(T t);
}
public interface Supplier<T> {
T get();
}
public interface Function<T, V> {
V apply(T t);
}
public abstract class Predicate<T> {
boolean test(T t);
}
Reactor – Stream
● Streams allow for composition of functions on data
– Callback++
– Netflix RxJava Observable, JDK 8 Stream
Stream<String> str;
str.map(String::toUpperCase)
.filter(new Predicate() {
public boolean test(String s) { … }
})
.consume(s → log.info(“consumed string {}”, s));
Reactor – Promise
● Promises allow for composition of functions on data
– Share common functions with Stream
Promise<String> p;
String s = p
.onSuccess(s → log.info(“consumed string {}”, s))
.onFailure(t → log.error(t.getMessage(), t))
.onComplete(log.info(“complete”))
.await(5, SECONDS);
p.map(String::toUpperCase).consume(s → log.info(“UC: {}”, s));
Reactor – Processor
● Thin wrapper around Disruptor RingBuffer
– Converts Disruptor API to Reactor API
– Uber fast performance for #UberFastData
Processor<Buffer> proc;
Operation<Buffer> op = proc.prepare();
op.get().append(data).flip();
op.commit();
proc.batch(512, buff → buff.append(data).flip());
Reactor – Spring
● Helpers to integrate Reactor into ApplicationContext
– @EnableReactor for easy configuration
– Wiring annotated handlers
Reactor – Spring
@Configuration
@EnableReactor
public class ReactorConfiguration {
@Bean
public Reactor input(Environment env) {
return Reactors.reactor().env(env)
.dispatcher(RING_BUFFER).get();
}
@Bean
public Reactor output(Environment env) {
return Reactors.reactor().env(env)
.dispatcher(RING_BUFFER).get();
Reactor – Spring
@Component
public class SimpleHandler {
@Autowired
private Reactor reactor;
@Selector(“test.topic”)
public void onTestTopic(String s) {
// Handle data
}
}
Reactor – Spring
● DispatcherTaskExecutor
– Not really a high-scale TaskExecutor
– Used to get Spring components running in same thread as
Reactor Consumers
● ConversionService integration
●
PromiseHandlerMethodReturnValueHandler (!)
● ReactorSubscribableChannel
Reactor – Groovy
● First class citizen language implementation
– @CompileStatic ready
– Prominent use of Closure as Consumers, Functions and
more
– Operator overloading for elegant programming
– Full Reactor system Builder
Reactor – Groovy : Notification and Consumer
@CompileStatic
def welcome(){
reactor.on('greetings') { String s ->
reply “hello $s”
reply “how are you?”
}
reactor.notify 'greetings', 'Jon'
reactor.send('greetings', 'Stephane'){
println it
cancel()
}
}
Reactor – Groovy : Promises and Streams
def promise = Promises.task { longStuff(); 1 } get()
def transformation = c | { it + 1 }
transformation.await() == 2
def deferredStream = Streams.defer().get()
(deferredStream & { it > 2 }) << { send(it) }
deferredStream << 1 << 2 << 3 << 4
Reactor – Groovy : Environment
GroovyEnvironment.create {
environment {
defaultDispatcher = "test"
dispatcher('test') {
type = DispatcherType.SYNCHRONOUS
}
}
}
Reactor – Groovy : Environment
GroovyEnvironment.create {
reactor('test1') {
stream('test') {
consume{ ev->
log.info ev.data
}
}
on('test') {
reply it
}
}
}
Reactor – Extensive awesomeness
● TCP Client/Server, with a Netty 4 implementation
● Buffer tools
● Sequencer support, for event ordering
● Work Queue support, with OoB Java Chronicle
implementation
● Log Appender
Reactor – Roadmap
● 1.0 feature complete
– 1.0 M3 on its way
– 1.0 RC1 – within a week
– 1.0 GA – within a month
Reactor – Roadmap
● 1.1 Discussions
– StateBox: A safe tool for concurrent writes
– Better Timer management
– Spring XD, Spring 4
– Exploring Distributed Reactors
● Voice your interest and your use-case here
Reactor – Uber Community contributions
● Meltdown: A Clojure binding by @michaelklishin & @ifesdjeen
– https://github.com/clojurewerkz/meltdown
Reactor – Uber Community contributions
● High Performance Couchbase ingestion by @daschl
– http://nitschinger.at/Using-the-Reactor-Processor-for-High-Performance-TCP
● Benefits of using Reactor Processor, TCP and Batching
facilities
Learn More. Stay Connected.
● Github organization : http://github.com/reactor
● Follow-up:
– Spring XD
– Spring 4 WebSocket
– Grails and the realtime web
Talk to us on Twitter: @ProjectReactor
Find Session replays on YouTube: spring.io/video

Weitere ähnliche Inhalte

Was ist angesagt?

Streaming millions of Contact Center interactions in (near) real-time with Pu...
Streaming millions of Contact Center interactions in (near) real-time with Pu...Streaming millions of Contact Center interactions in (near) real-time with Pu...
Streaming millions of Contact Center interactions in (near) real-time with Pu...Frank Kelly
 
2010-02-09 Reactor Pattern & Event Driven Programming
2010-02-09 Reactor Pattern & Event Driven Programming2010-02-09 Reactor Pattern & Event Driven Programming
2010-02-09 Reactor Pattern & Event Driven ProgrammingLin Jen-Shin
 
Embedded Mirror Maker
Embedded Mirror MakerEmbedded Mirror Maker
Embedded Mirror MakerSimon Suo
 
Asynchronous stream processing with Akka Streams
Asynchronous stream processing with Akka StreamsAsynchronous stream processing with Akka Streams
Asynchronous stream processing with Akka StreamsJohan Andrén
 
Project Deimos
Project DeimosProject Deimos
Project DeimosSimon Suo
 
Meteor Boulder meetup #1
Meteor Boulder meetup #1Meteor Boulder meetup #1
Meteor Boulder meetup #1Robert Dickert
 
Reactive programming with Pivotal's reactor
Reactive programming with Pivotal's reactorReactive programming with Pivotal's reactor
Reactive programming with Pivotal's reactorVMware Tanzu
 
Functional Load Testing with Gatling
Functional Load Testing with GatlingFunctional Load Testing with Gatling
Functional Load Testing with GatlingGerald Muecke
 
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksVUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksMarcus Denker
 
Gatling workshop lets test17
Gatling workshop lets test17Gatling workshop lets test17
Gatling workshop lets test17Gerald Muecke
 
Best Practices: Large Scale Multiphysics
Best Practices: Large Scale MultiphysicsBest Practices: Large Scale Multiphysics
Best Practices: Large Scale Multiphysicsinside-BigData.com
 
Write code that writes code!
Write code that writes code!Write code that writes code!
Write code that writes code!Jason Feinstein
 
Event Sourcing on AWS Using Akka in Java
Event Sourcing on AWS Using Akka in JavaEvent Sourcing on AWS Using Akka in Java
Event Sourcing on AWS Using Akka in JavaDaniel Pfeiffer
 
Scaling real world applications using gevent
Scaling real world applications using geventScaling real world applications using gevent
Scaling real world applications using geventaalokthemagnificient
 

Was ist angesagt? (15)

Streaming millions of Contact Center interactions in (near) real-time with Pu...
Streaming millions of Contact Center interactions in (near) real-time with Pu...Streaming millions of Contact Center interactions in (near) real-time with Pu...
Streaming millions of Contact Center interactions in (near) real-time with Pu...
 
2010-02-09 Reactor Pattern & Event Driven Programming
2010-02-09 Reactor Pattern & Event Driven Programming2010-02-09 Reactor Pattern & Event Driven Programming
2010-02-09 Reactor Pattern & Event Driven Programming
 
Reactor in Action
Reactor in ActionReactor in Action
Reactor in Action
 
Embedded Mirror Maker
Embedded Mirror MakerEmbedded Mirror Maker
Embedded Mirror Maker
 
Asynchronous stream processing with Akka Streams
Asynchronous stream processing with Akka StreamsAsynchronous stream processing with Akka Streams
Asynchronous stream processing with Akka Streams
 
Project Deimos
Project DeimosProject Deimos
Project Deimos
 
Meteor Boulder meetup #1
Meteor Boulder meetup #1Meteor Boulder meetup #1
Meteor Boulder meetup #1
 
Reactive programming with Pivotal's reactor
Reactive programming with Pivotal's reactorReactive programming with Pivotal's reactor
Reactive programming with Pivotal's reactor
 
Functional Load Testing with Gatling
Functional Load Testing with GatlingFunctional Load Testing with Gatling
Functional Load Testing with Gatling
 
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksVUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
 
Gatling workshop lets test17
Gatling workshop lets test17Gatling workshop lets test17
Gatling workshop lets test17
 
Best Practices: Large Scale Multiphysics
Best Practices: Large Scale MultiphysicsBest Practices: Large Scale Multiphysics
Best Practices: Large Scale Multiphysics
 
Write code that writes code!
Write code that writes code!Write code that writes code!
Write code that writes code!
 
Event Sourcing on AWS Using Akka in Java
Event Sourcing on AWS Using Akka in JavaEvent Sourcing on AWS Using Akka in Java
Event Sourcing on AWS Using Akka in Java
 
Scaling real world applications using gevent
Scaling real world applications using geventScaling real world applications using gevent
Scaling real world applications using gevent
 

Ähnlich wie Reactor spring one2gx_2013_0902-final

Reactor grails realtime web devoxx 2013
Reactor grails realtime web   devoxx 2013Reactor grails realtime web   devoxx 2013
Reactor grails realtime web devoxx 2013Stéphane Maldini
 
Intro to Reactor
Intro to ReactorIntro to Reactor
Intro to ReactorJon Brisbin
 
RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 SlidesYarikS
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaRick Warren
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatientGrant Steinfeld
 
RxJS101 - What you need to know to get started with RxJS tomorrow
RxJS101 - What you need to know to get started with RxJS tomorrowRxJS101 - What you need to know to get started with RxJS tomorrow
RxJS101 - What you need to know to get started with RxJS tomorrowViliam Elischer
 
Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2JollyRogers5
 
Reactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary GrygleskiReactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary GrygleskiPolyglotMeetups
 
Concurrency (Fisher Syer S2GX 2010)
Concurrency (Fisher Syer S2GX 2010)Concurrency (Fisher Syer S2GX 2010)
Concurrency (Fisher Syer S2GX 2010)Dave Syer
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for AndroidTomáš Kypta
 
Ring: Web Apps in Idiomatic Clojure
Ring: Web Apps in Idiomatic ClojureRing: Web Apps in Idiomatic Clojure
Ring: Web Apps in Idiomatic ClojureMark McGranaghan
 
Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and TomorrowVMware Tanzu
 
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
 
Petro Gordiievych "From Java 9 to Java 12"
Petro Gordiievych "From Java 9 to Java 12"Petro Gordiievych "From Java 9 to Java 12"
Petro Gordiievych "From Java 9 to Java 12"LogeekNightUkraine
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteorKen Ono
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteorKen Ono
 
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)Rick Hightower
 
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java:  Promises and Streams with Reakt (JavaOne Talk 2016)Reactive Java:  Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)Rick Hightower
 
Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysManuel Bernhardt
 

Ähnlich wie Reactor spring one2gx_2013_0902-final (20)

Reactor grails realtime web devoxx 2013
Reactor grails realtime web   devoxx 2013Reactor grails realtime web   devoxx 2013
Reactor grails realtime web devoxx 2013
 
Intro to Reactor
Intro to ReactorIntro to Reactor
Intro to Reactor
 
RxJava2 Slides
RxJava2 SlidesRxJava2 Slides
RxJava2 Slides
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
 
RxJS101 - What you need to know to get started with RxJS tomorrow
RxJS101 - What you need to know to get started with RxJS tomorrowRxJS101 - What you need to know to get started with RxJS tomorrow
RxJS101 - What you need to know to get started with RxJS tomorrow
 
Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2Intro to Reactive Thinking and RxJava 2
Intro to Reactive Thinking and RxJava 2
 
Reactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary GrygleskiReactive for the Impatient - Mary Grygleski
Reactive for the Impatient - Mary Grygleski
 
Concurrency (Fisher Syer S2GX 2010)
Concurrency (Fisher Syer S2GX 2010)Concurrency (Fisher Syer S2GX 2010)
Concurrency (Fisher Syer S2GX 2010)
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
Ring: Web Apps in Idiomatic Clojure
Ring: Web Apps in Idiomatic ClojureRing: Web Apps in Idiomatic Clojure
Ring: Web Apps in Idiomatic Clojure
 
Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and Tomorrow
 
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
 
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
Javantura v3 - Going Reactive with RxJava – Hrvoje CrnjakJavantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
 
Petro Gordiievych "From Java 9 to Java 12"
Petro Gordiievych "From Java 9 to Java 12"Petro Gordiievych "From Java 9 to Java 12"
Petro Gordiievych "From Java 9 to Java 12"
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteor
 
Using redux and angular 2 with meteor
Using redux and angular 2 with meteorUsing redux and angular 2 with meteor
Using redux and angular 2 with meteor
 
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
 
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java:  Promises and Streams with Reakt (JavaOne Talk 2016)Reactive Java:  Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
 
Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDays
 

Mehr von Stéphane Maldini

Multi-service reactive streams using Spring, Reactor, RSocket
Multi-service reactive streams using Spring, Reactor, RSocketMulti-service reactive streams using Spring, Reactor, RSocket
Multi-service reactive streams using Spring, Reactor, RSocketStéphane Maldini
 
The Future of Reactive Architectures
The Future of Reactive ArchitecturesThe Future of Reactive Architectures
The Future of Reactive ArchitecturesStéphane Maldini
 
What's new in Reactor Californium
What's new in Reactor CaliforniumWhat's new in Reactor Californium
What's new in Reactor CaliforniumStéphane Maldini
 
Spring boot 2.0 reactive bits (June 2018)
Spring boot 2.0 reactive bits (June 2018)Spring boot 2.0 reactive bits (June 2018)
Spring boot 2.0 reactive bits (June 2018)Stéphane Maldini
 
Reactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and SpringReactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and SpringStéphane Maldini
 
Introduction to Reactive Streams and Reactor 2.5
Introduction to Reactive Streams and Reactor 2.5Introduction to Reactive Streams and Reactor 2.5
Introduction to Reactive Streams and Reactor 2.5Stéphane Maldini
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive ProgrammingStéphane Maldini
 
Designing for Distributed Systems with Reactor and Reactive Streams
Designing for Distributed Systems with Reactor and Reactive StreamsDesigning for Distributed Systems with Reactor and Reactive Streams
Designing for Distributed Systems with Reactor and Reactive StreamsStéphane Maldini
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesStéphane Maldini
 
Springone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and ReactorSpringone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and ReactorStéphane Maldini
 
Groovy reactor grails realtime web devoxx 2013
Groovy reactor grails realtime web   devoxx 2013Groovy reactor grails realtime web   devoxx 2013
Groovy reactor grails realtime web devoxx 2013Stéphane Maldini
 

Mehr von Stéphane Maldini (14)

The value of reactive
The value of reactiveThe value of reactive
The value of reactive
 
Multi-service reactive streams using Spring, Reactor, RSocket
Multi-service reactive streams using Spring, Reactor, RSocketMulti-service reactive streams using Spring, Reactor, RSocket
Multi-service reactive streams using Spring, Reactor, RSocket
 
The Future of Reactive Architectures
The Future of Reactive ArchitecturesThe Future of Reactive Architectures
The Future of Reactive Architectures
 
Spring Cloud Gateway
Spring Cloud GatewaySpring Cloud Gateway
Spring Cloud Gateway
 
What's new in Reactor Californium
What's new in Reactor CaliforniumWhat's new in Reactor Californium
What's new in Reactor Californium
 
Spring boot 2.0 reactive bits (June 2018)
Spring boot 2.0 reactive bits (June 2018)Spring boot 2.0 reactive bits (June 2018)
Spring boot 2.0 reactive bits (June 2018)
 
Reactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and SpringReactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and Spring
 
Introduction to Reactive Streams and Reactor 2.5
Introduction to Reactive Streams and Reactor 2.5Introduction to Reactive Streams and Reactor 2.5
Introduction to Reactive Streams and Reactor 2.5
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive Programming
 
Designing for Distributed Systems with Reactor and Reactive Streams
Designing for Distributed Systems with Reactor and Reactive StreamsDesigning for Distributed Systems with Reactor and Reactive Streams
Designing for Distributed Systems with Reactor and Reactive Streams
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServices
 
Springone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and ReactorSpringone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and Reactor
 
Groovy reactor grails realtime web devoxx 2013
Groovy reactor grails realtime web   devoxx 2013Groovy reactor grails realtime web   devoxx 2013
Groovy reactor grails realtime web devoxx 2013
 
Eventsggx
EventsggxEventsggx
Eventsggx
 

Kürzlich hochgeladen

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 

Kürzlich hochgeladen (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 

Reactor spring one2gx_2013_0902-final

  • 1. © 2013 SpringOne 2GX. All rights reserved. Do not distribute without permission. Reactor: A Foundation for Reactive FastData Applications on the JVM Jon Brisbin – @j_brisbin Stephane Maldini – @smaldini
  • 2. The Spring IO Directory
  • 3. Reactor – Housekeeping ● Tweet questions during the presentation – @ProjectReactor – @j_brisbin – @smaldini ● Stop us anywhere if you have a question – There are no stupid questions, only stupid answers!
  • 4. Reactor – What is it? ● Reactor is a foundational library – Plays in grey area between user-level and lower-level abstractions – Components and application cores can be built on Reactor – Drivers, servers, data integration libraries, domain integration libraries, Evented architectures
  • 5. Reactor – What is it? ● Reactor is a distillation of other libraries and best-practices – Elements of other patterns and libraries surface throughout Reactor's abstractions http://stackoverflow.com/questions/16595393/akka-or-reactor
  • 6. Reactor – What can I build with it? ● Reactor applications are reactive – Reactive Extensions in .NET – Netflix RxJava – Observer pattern ● Reactor applications route events based on a Selector – Like a routing topic, but can be any object – Regex, URI template, Class.isAssingableFrom, custom logic
  • 8. Reactor – What does it look like? Environment env = new Environment(); Reactor reactor = Reactors.reactor() .env(env) .dispatcher(RING_BUFFER) .get(); reactor.on($(“topic”), (Event<String> ev) → { System.out.println(“Hello “ + ev.getData()); }); reactor.notify(“topic”, Event.wrap(“John Doe”));
  • 9. Reactor – Selectors ● Selectors are the left-hand side of an equality comparison – A Selector can be created from any object using $(obj) (or the long form: Selectors.object(obj)) – A Selector can extract data from the matched key – Predicate<T> Selectors can be created to match on domain-specific criteria like header values
  • 10. Reactor – Selectors ● A RegexSelector will match a String by executing the regex over it – R(“some.(.*)”) – Selectors.regex(“some.(.*)”) reactor.on(R(“some.(.+)”), (Event<String> ev) → { // s will be 'topic' String s = ev.getHeaders().get(“group1”); }); reactor.notify(“some.topic”, Event.wrap(“John Doe”));
  • 11. Reactor – Selectors ● A UriTemplateSelector will match a String by extracting bits from a URI – U(“/some/{path}”) – Selectors.uri(“/some/{path}”) reactor.on(U(“/some/{topic}”), (Event<String> ev) → { // s will be 'topic' String s = ev.getHeaders().get(“topic”); }); reactor.notify(“/some/topic”, Event.wrap(“John Doe”));
  • 12. Reactor – Consumer, Function, Supplier, Predicate public interface Consumer<T> { void accept(T t); } public interface Supplier<T> { T get(); } public interface Function<T, V> { V apply(T t); } public abstract class Predicate<T> { boolean test(T t); }
  • 13. Reactor – Stream ● Streams allow for composition of functions on data – Callback++ – Netflix RxJava Observable, JDK 8 Stream Stream<String> str; str.map(String::toUpperCase) .filter(new Predicate() { public boolean test(String s) { … } }) .consume(s → log.info(“consumed string {}”, s));
  • 14. Reactor – Promise ● Promises allow for composition of functions on data – Share common functions with Stream Promise<String> p; String s = p .onSuccess(s → log.info(“consumed string {}”, s)) .onFailure(t → log.error(t.getMessage(), t)) .onComplete(log.info(“complete”)) .await(5, SECONDS); p.map(String::toUpperCase).consume(s → log.info(“UC: {}”, s));
  • 15. Reactor – Processor ● Thin wrapper around Disruptor RingBuffer – Converts Disruptor API to Reactor API – Uber fast performance for #UberFastData Processor<Buffer> proc; Operation<Buffer> op = proc.prepare(); op.get().append(data).flip(); op.commit(); proc.batch(512, buff → buff.append(data).flip());
  • 16. Reactor – Spring ● Helpers to integrate Reactor into ApplicationContext – @EnableReactor for easy configuration – Wiring annotated handlers
  • 17. Reactor – Spring @Configuration @EnableReactor public class ReactorConfiguration { @Bean public Reactor input(Environment env) { return Reactors.reactor().env(env) .dispatcher(RING_BUFFER).get(); } @Bean public Reactor output(Environment env) { return Reactors.reactor().env(env) .dispatcher(RING_BUFFER).get();
  • 18. Reactor – Spring @Component public class SimpleHandler { @Autowired private Reactor reactor; @Selector(“test.topic”) public void onTestTopic(String s) { // Handle data } }
  • 19. Reactor – Spring ● DispatcherTaskExecutor – Not really a high-scale TaskExecutor – Used to get Spring components running in same thread as Reactor Consumers ● ConversionService integration ● PromiseHandlerMethodReturnValueHandler (!) ● ReactorSubscribableChannel
  • 20. Reactor – Groovy ● First class citizen language implementation – @CompileStatic ready – Prominent use of Closure as Consumers, Functions and more – Operator overloading for elegant programming – Full Reactor system Builder
  • 21. Reactor – Groovy : Notification and Consumer @CompileStatic def welcome(){ reactor.on('greetings') { String s -> reply “hello $s” reply “how are you?” } reactor.notify 'greetings', 'Jon' reactor.send('greetings', 'Stephane'){ println it cancel() } }
  • 22. Reactor – Groovy : Promises and Streams def promise = Promises.task { longStuff(); 1 } get() def transformation = c | { it + 1 } transformation.await() == 2 def deferredStream = Streams.defer().get() (deferredStream & { it > 2 }) << { send(it) } deferredStream << 1 << 2 << 3 << 4
  • 23. Reactor – Groovy : Environment GroovyEnvironment.create { environment { defaultDispatcher = "test" dispatcher('test') { type = DispatcherType.SYNCHRONOUS } } }
  • 24. Reactor – Groovy : Environment GroovyEnvironment.create { reactor('test1') { stream('test') { consume{ ev-> log.info ev.data } } on('test') { reply it } } }
  • 25. Reactor – Extensive awesomeness ● TCP Client/Server, with a Netty 4 implementation ● Buffer tools ● Sequencer support, for event ordering ● Work Queue support, with OoB Java Chronicle implementation ● Log Appender
  • 26. Reactor – Roadmap ● 1.0 feature complete – 1.0 M3 on its way – 1.0 RC1 – within a week – 1.0 GA – within a month
  • 27. Reactor – Roadmap ● 1.1 Discussions – StateBox: A safe tool for concurrent writes – Better Timer management – Spring XD, Spring 4 – Exploring Distributed Reactors ● Voice your interest and your use-case here
  • 28. Reactor – Uber Community contributions ● Meltdown: A Clojure binding by @michaelklishin & @ifesdjeen – https://github.com/clojurewerkz/meltdown
  • 29. Reactor – Uber Community contributions ● High Performance Couchbase ingestion by @daschl – http://nitschinger.at/Using-the-Reactor-Processor-for-High-Performance-TCP ● Benefits of using Reactor Processor, TCP and Batching facilities
  • 30. Learn More. Stay Connected. ● Github organization : http://github.com/reactor ● Follow-up: – Spring XD – Spring 4 WebSocket – Grails and the realtime web Talk to us on Twitter: @ProjectReactor Find Session replays on YouTube: spring.io/video