reactive vert.x
DESCRIPTION
The benefits of using reactive extensions with Vert.x. Talk given at the Vancouver Reactive Programmers Meetup: http://www.meetup.com/Vancouver-Reactive-Programmers/events/181183662/ Related source code: https://github.com/ddossot/vertx-react-demoTRANSCRIPT
REACTIVE
Event-Driven
Message passingEvent bus
Non-blocking IO
Scalable
Distributed event-busLocation transparency
Clustered in-memory cache
Resilient
Module and verticle isolationWorker processes
Automatic HA failover
Responsive
“Don't block the event loop!”Time-outs
Event-bus “back pressure”
JavaRubyScala
ClojurePythonGroovy
JavaScript...
PHP
Polyglot Friction
Andrew Cholakianhttp://blog.andrewvc.com/vertx-node-on-ropes
Why ?
https://rx.codeplex.com/
https://github.com/Netflix/RxJava
https://github.com/vert-x/mod-rxvertx
Callback HelleventBus.<JsonObject> sendWithTimeout(metricsAddress, METERS_BUS_REQUEST, 1000L, ar1 -> {
JsonObject metersData = ar1.succeeded() ? ar1.result().body() : new JsonObject();
eventBus.<JsonObject> sendWithTimeout(metricsAddress, HISTOGRAMS_BUS_REQUEST, 1000L, ar2 -> {
JsonObject histogramData = ar2.succeeded() ? ar2.result().body() : new JsonObject();
processData(metersData.mergeIn(histogramData)); });});
Callback HelpObservable<JsonObject> observeMeters = eventBus.<JsonObject, JsonObject> send(metricsAddress, METERS_BUS_REQUEST) .map(msg -> msg.body()) .timeout(1L, SECONDS, from(new JsonObject()));
Observable<JsonObject> observeHistograms = eventBus.<JsonObject, JsonObject> send(metricsAddress, HISTOGRAMS_BUS_REQUEST) .map(msg -> msg.body()) .timeout(1L, SECONDS, from(new JsonObject()));
zip(observeMeters, observeHistograms, (jo1, jo2) -> jo1.mergeIn(jo2)) .subscribe(data -> processData(data));
http://careers.unbounce.com
@ddossot