SlideShare ist ein Scribd-Unternehmen logo
1 von 81
Downloaden Sie, um offline zu lesen
SPRINGONE2GX
WASHINGTON DC
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Intro To
Reactive Programming
Stephane Maldini
Rossen Stoyanchev
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
About the Speakers
• Stephane Maldini
• Reactor Project Lead
• Reactive Streams Spec contributor
• Rossen Stoyanchev
• Spring Framework committer
• Spring MVC
• WebSocket messaging (STOMP, SockJS)
2
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Motivation
3
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Long Running Shift to Concurrency
For 30 years computer performance driven by Moore's Law;
from now on, it will be driven by Amdahl's Law.
Moore's Law is delivering
more cores but not faster cores.
March 2006
4
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Amdahl’s Law
5
Theoretical max
speedup using multiple
processors?
Limited by the time
needed for sequential
processing.
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Scale Up
• Remember SOA ? EJB 1 ?
• distributed components, then services
• functional boundaries between system components
• location transparent resources pooled
• … but it didn’t do well
• complex / expensive solutions
• full-stack approach
• overhead not factored in: latency failure tolerance
• Ended up in hype failure mockeries and hacker news rants
6
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Internet Scale
• Social media became mainstream
• massive scale
• Background Processing and pooled resources regain interest
• everything “write-heavy” -- candidate for async handling
• e.g. a tweet
• Push-based servers start to proliferate
• async response handling (e.g. facebook messages)
7
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Cloud Scale
• “Cloud-ready” systems began to spread around 2012
• AWS, open-source PaaS democratization
• Tech giants expose internal distributed stack
• Twitter, Google, Netflix...
• Tools to address core concerns of distributed systems
• concurrency, service discovery, monitoring
8
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Wait! Another traffic spike: IoT
9
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Scale Out
• There are limits to scale the monolith way
• cost efficiency aside
• Memory overuse
• large thread pools, application footprint
• CPU underuse
• blocking I/O (DB, remote service)
10
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Tales of Time and Space
11
• Massive scale requires higher efficiency
• respect physical laws
• speed of light dampens inter-service communication
• Pooling resources simply not enough
• need to coordinate, compose, orchestrate data flows
• Non-blocking must be embraced fundamentally
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Non-Blocking Architecture
12
• Non-blocking requires profound change
• can’t write imperative code
• can’t assume single thread of control (e.g. exception handling)
• Must deal with async results
• listener/callbacks become unwieldy with nested composition
• Everything becomes an event stream
• e.g. from Input/OutputStream to stream of events
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Programming
13
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• “Reactive” is used broadly to define event-driven systems
• UI events, network protocols
• Now also entering the domain of application/business logic
• Non-blocking event-driven architecture
Generally speaking…
14
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Manifesto
15
• Reflects the emerging field of scalable, non-blocking applications
• A hark back to other successful manifestos
• Well articulated but very broad strokes
• Defines qualities of reactive systems
• For reactive programming we need concrete tools
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Programming in Context
• To build reactive apps we need two essential building blocks
• Contract for interop between non-blocking components
• Reactive Streams spec
• API for composing asynchronous programs
• e.g. Reactive Extensions
16
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Myths about “Reactive”
• Async / concurrent == reactive ?
• easy to end up with too many threads
• fill up hand-off queue
• Must be async to be reactive ?
• nope but must be agnostic to source of concurrency
• Reactive is the domain of specific programming languages ?
• language features can help
• e.g. JDK 8 lambda
17
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Streams
Specification for the JVM
18
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Specification Goals
• Govern the exchange of data across async boundaries
• Use back-pressure for flow control
• Fast sources should not overwhelm slower consumers
• Provide API types, TCK
19
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• When publisher maintains higher rate for extended time
• queues grow without bounds
• Back-pressure allows a subscriber to control queue bounds
• subscriber requests # of elements
• publisher produces up to # of requested
• If source can’t be controlled (e.g. mouse movement clock tick)
• publisher may buffer or drop
• must obey # of requested elements
Back-Pressure
20
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
public interface Publisher<T> {
void subscribe(Subscriber<? super T> s);
}
21
public interface Subscription {
void request(long n);
void cancel();
}
public interface Subscriber<T> {
void onSubscribe(Subscription s);
void onNext(T t);
void onError(Throwable t);
void onComplete();
}
All are void methods…
one-way, message style
public interface Processor<T R> extends Subscriber<T> Publisher<R> {
}
API Types
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 22
onSubscribe
onNext*
(onError|onComplete)?
Publisher
Subscriber
Subscription
Reactive Streams API
request(n)
cancel()
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 23
Reactive Streams: Message Passing
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 26
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 27
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 28
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 29
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 30
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 31
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• No concurrent calls from Publisher to Subscriber (1.3) or vice versa (2.7)
• A Subscriber may perform work synchronously or asynchronously
• either way must be non-blocking (2.2)
• Upper bound on open recursion required (3.3)
• onNext → request → onNext → … → StackOverflow
• No exceptions can be raised except NPE for null input (1.9 2.13)
• Publisher calls onError(Throwable)
• Subscriber cancels subscription
Spec Rules
35
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
What does request(n) mean?
• N represents an element count
• relative (byte chunks) more so than absolute (# of bytes)
• Boundaries
• Must be > 0
• Long.MAX_VALUE means unbounded read
• So does overflow of N
36
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Request some receive all request more ... (“stop-and-wait”)
• request signal equivalent to an ack
• Pre-fill buffer of certain capacity (“pre-fetch”)
• request again when buffer falls below some threshold
• more in-flight data → more risk
• Request using timer/scheduler facility (“poll”)
• Adapt to network or processing latency (“dynamic”)
• find and pick the best request size
Request Strategies
37
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Demo:
Publisher & Subscriber, Back-pressure, TCK verification
Demo source, TCK test
38
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Sync is explicitly allowed -- 2.2 3.2 3.10 3.11
• If Publisher/Subscriber are both sync → open recursion
• not always an issue e.g. single item Publisher
• The picture is different in a processing chain (vs. single Publisher-Subscriber)
• async hand-off is likely needed at some stage
• but not at every stage
• Async is not the goal non-blocking is the overall objective
Async vs Sync
39
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Async vs Sync (continued)
• Implementations are free to choose how to do this
• As long as they comply with all the rules
• Generally speaking the burden is on the Publisher
• make async or sync calls as necessary
• prevent open recursion
• sequential signals
• Subscribers can largely ignore such concerns
40
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Streams → JDK 9 Flow.java
• No single best fluent async/parallel API in Java [1]
• CompletableFuture/CompletionStage
• continuation-style programming on futures
• java.util.stream
• multi-stage/parallel, “pull”-style operations on collections
• No "push"-style API for items as they become available from active source
Java “concurrency-interest” list:
[1] initial announcement [2] why in the JDK? [3] recent update
41
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
JDK 9 java.util.concurrent
• java.util.concurrent.Flow
• Flow.Publisher Flow.Subscriber Flow.Subscription ...
• Flow.consume(...) and Flow.stream(...)
• Tie-ins to CompletableFuture and java.util.Stream
• SubmissionPublisher
• turn any kind of source to Publisher
• Executor-based delivery to subscribers w/ bounded (ring) buffer
• submit and offer strategies (block or drop) to publish
42
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
API For Async Composition
43
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 44
Application
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 45
Application
Reactive
Streams
HTTP
Data
Broker
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 46
Application
Reactive
Streams
HTTP
Data
Broker
?
API to compose
asynchronous
programs?
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Working with Streams
• Non-blocking services return Publisher<T> instead of <T>
• How do you attach further processing?
• Reactive Streams is a callback-based API
• becomes very nested quickly
• Need something more declarative
• it’s beyond the scope of Reactive Streams
47
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Publisher represents a stream of data
• It’s natural to apply operations functional-style
• like the Java 8 Stream
• Need API for composing async logic
• rise above callbacks
Stream Operations
48
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactor Stream
• Project Reactor provides a Stream API
• Reactive Streams Publisher + composable operations
49
Streams.just('a' 'b' 'c')
.take(2)
.map(Character::toUpperCase)
.consume(System.out::println);
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Demo:
Reactor Stream, Back-Pressure
Demo source
50
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reactive Extensions (Rx)
• Stream composition API based on Observer pattern
• Originated at Microsoft, work by Erik Meijer
• Implemented for different languages -- RxJava, RxJS, Rx.NET, …
51
Observable.just('a', 'b', 'c')
.take(2)
.map(Character::toUpperCase)
.subscribe(System.out::println);
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
RxJava and Reactive Streams
• RxJava 1.x predates Reactive Streams and doesn’t implement it directly
• Very similar concepts, different names
• Observable-Observer vs Publisher-Subscriber
• RxJava supports “reactive pull” back-pressure
• RxJava 1.x - Reactive Streams bridge
52
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Java 8 Streams best suited for collections
• Observer and Iterator actually very closely related
• same except push vs pull
• Observable however can represent any source including collections
• RxJava 2 is planned to support Java 8 Stream
• Observable.from(Iterable) + implement java.util.Stream
Rx vs Java 8 Streams
53
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Demo:
RxJava, Back-Pressure, Reactive Streams Bridge
Demo class, TCK test
54
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
RxJava vs Reactor
• RxJava is a great choice for composition in applications
• many operators, polyglot (client/server), well-documented
• Reactive Streams is ideal for use in library APIs
• remain agnostic to composition
• Reactor is positioned as foundation for libraries
• essential Reactive Streams infrastructure + core operators
• also used in high volume applications
55
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Head Start with
Stream Composition
56
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Operators: reactivex.io Alphabetical List
Aggregate, All, Amb, and_, And, Any, apply, as_blocking, AsObservable, AssertEqual, asyncAction, asyncFunc, Average, averageDouble, averageFloat, averageInteger,
averageLong, blocking, Buffer, bufferWithCount, bufferWithTime, bufferWithTimeOrCount, byLine, cache, case, Cast, Catch, catchException, collect, collect (RxScala
version of Filter), CombineLatest, combineLatestWith, Concat, concat_all, concatMap, concatMapObserver, concatAll, concatWith, Connect, connect_forever, cons,
Contains, controlled, Count, countLong, Create, cycle, Debounce, decode, DefaultIfEmpty, Defer, deferFuture, Delay, delaySubscription, delayWithSelector,
Dematerialize, Distinct, DistinctUntilChanged, Do, doAction, doOnCompleted, doOnEach, doOnError, doOnRequest, doOnSubscribe, doOnTerminate, doOnUnsubscribe, doseq,
doWhile, drop, dropRight, dropUntil, dropWhile, ElementAt, ElementAtOrDefault, Empty, empty?, encode, ensures, error, every, exclusive, exists, expand, failWith,
Filter, filterNot, Finally, finallyAction, finallyDo, find, findIndex, First, FirstOrDefault, firstOrElse, FlatMap, flatMapFirst, flatMapIterable,
flatMapIterableWith, flatMapLatest, flatMapObserver, flatMapWith, flatMapWithMaxConcurrent, flat_map_with_index, flatten, flattenDelayError, foldl, foldLeft, for,
forall, ForEach, forEachFuture, forIn, forkJoin, From, fromAction, fromArray, FromAsyncPattern, fromCallable, fromCallback, FromEvent, FromEventPattern, fromFunc0,
from_future, from_iterable, from_list, fromNodeCallback, fromPromise, fromRunnable, Generate, generateWithAbsoluteTime, generateWithRelativeTime, generator,
GetEnumerator, getIterator, GroupBy, GroupByUntil, GroupJoin, head, headOption, headOrElse, if, ifThen, IgnoreElements, indexOf, interleave, interpose, Interval,
into, isEmpty, items, Join, join (string), jortSort, jortSortUntil, Just, keep, keep-indexed, Last, lastOption, LastOrDefault, lastOrElse, Latest, latest (Rx.rb
version of Switch), length, let, letBind, limit, LongCount, ManySelect, Map, map (RxClojure version of Zip), MapCat, mapCat (RxClojure version of Zip), map-indexed,
map_with_index, Materialize, Max, MaxBy, Merge, mergeAll, merge_concurrent, mergeDelayError, mergeObservable, mergeWith, Min, MinBy, MostRecent, Multicast, nest,
Never, Next, Next (BlockingObservable version), none, nonEmpty, nth, ObserveOn, ObserveOnDispatcher, observeSingleOn, of, of_array, ofArrayChanges, of_enumerable,
of_enumerator, ofObjectChanges, OfType, ofWithScheduler, onBackpressureBlock, onBackpressureBuffer, onBackpressureDrop, OnErrorResumeNext, onErrorReturn,
onExceptionResumeNext, orElse, pairs, pairwise, partition, partition-all, pausable, pausableBuffered, pluck, product, Publish, PublishLast, publish_synchronized,
publishValue, raise_error, Range, Reduce, reductions, RefCount, Repeat, repeat_infinitely, repeatWhen, Replay, rescue_error, rest, Retry, retry_infinitely,
retryWhen, Return, returnElement, returnValue, runAsync, Sample, Scan, scope, Select (alternate name of Map), select (alternate name of Filter), selectConcat,
selectConcatObserver, SelectMany, selectManyObserver, select_switch, selectSwitch, selectSwitchFirst, selectWithMaxConcurrent, select_with_index, seq,
SequenceEqual, sequence_eql?, SequenceEqualWith, Serialize, share, shareReplay, shareValue, Single, SingleOrDefault, singleOption, singleOrElse, size, Skip,
SkipLast, skipLastWithTime, SkipUntil, skipUntilWithTime, SkipWhile, skip_while_with_index, skip_with_time, slice, sliding, slidingBuffer, some, sort, sort-by,
sorted-list-by, split, split-with, Start, startAsync, startFuture, StartWith, stringConcat, stopAndWait, subscribe, SubscribeOn, SubscribeOnDispatcher,
subscribeOnCompleted, subscribeOnError, subscribeOnNext, Sum, sumDouble, sumFloat, sumInteger, sumLong, Switch, switchCase, switchIfEmpty, switchLatest, switchMap,
switchOnNext, Synchronize, Take, take_with_time, takeFirst, TakeLast, takeLastBuffer, takeLastBufferWithTime, takeLastWithTime, takeRight (see also: TakeLast),
TakeUntil, takeUntilWithTime, TakeWhile, take_while_with_index, tail, tap, tapOnCompleted, tapOnError, tapOnNext, Then, thenDo, Throttle, throttleFirst,
throttleLast, throttleWithSelector, throttleWithTimeout, Throw, throwError, throwException, TimeInterval, Timeout, timeoutWithSelector, Timer, Timestamp, To, to_a,
ToArray, ToAsync, toBlocking, toBuffer, to_dict, ToDictionary, ToEnumerable, ToEvent, ToEventPattern, ToFuture, to_h, toIndexedSeq, toIterable, toIterator, ToList,
ToLookup, toMap, toMultiMap, ToObservable, toSet, toSortedList, toStream, ToTask, toTraversable, toVector, tumbling, tumblingBuffer, unsubscribeOn, Using, When,
Where, while, whileDo, Window, windowWithCount, windowWithTime, windowWithTimeOrCount, windowed, withFilter, withLatestFrom, Zip, zipArray, zipWith, zipWithIndex
57
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Operators: rx.Observable
all, amb, ambWith, asObservable, buffer, cache, cast, collect, combineLatest, compose,
concat, concatMap, concatWith, contains, count, countLong, create, debounce,
defaultIfEmpty, defer, delay, delaySubscription, dematerialize, distinct,
distinctUntilChanged, doOnCompleted, doOnEach, doOnError, doOnNext, doOnRequest,
doOnSubscribe, doOnTerminate, doOnUnsubscribe, elementAt, elementAtOrDefault, empty,
error, exists, filter, finallyDo, first, firstOrDefault, flatMap, flatMapIterable, from,
groupBy, groupJoin, ignoreElements, interval, isEmpty, join, just, last, lastOrDefault,
lift, limit, map, materialize, merge, mergeDelayError, mergeWith, nest, never,
observeOn, ofType, onBackpressureBlock, onBackpressureBuffer, onBackpressureDrop,
onBackpressureLatest, onErrorResumeNext, onErrorReturn, onExceptionResumeNext, publish,
range, reduce, repeat, repeatWhen, replay, retry, retryWhen, sample, scan,
sequenceEqual, serialize, share, single, singleOrDefault, skip, skipLast, skipUntil,
skipWhile, startWith, subscribeOn, switchIfEmpty, switchMap, switchOnNext, take,
takeFirst, takeLast, takeLastBuffer, takeUntil, takeWhile, throttleFirst, throttleLast,
throttleWithTimeout, timeInterval, timeout, timer, timestamp, toList, toMap, toMultimap,
toSortedList, unsubscribeOn, using, window, withLatestFrom, zip, zipWith
58
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Operators: what can you do with sequences?
• Originate -- fixed values, arrays, ranges, from scratch
• Reduce -- filter, accumulate, aggregate, partition
• Transform -- create new type of sequence
• Combine -- concatenate, merge, pair
• Control -- overflow, errors
59
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Compose Non-blocking Service Layer
Blocking:
List<String> findUsers(String skill);
LinkedInProfile getConnections(String id);
TwitterProfile getTwitterProfile(String id);
FacebookProfile getFacebookProfile(String id);
Non-Blocking:
Observable<String> findUsers(String skill);
Observable<LinkedInProfile> getConnections(String id);
Observable<TwitterProfile> getTwitterProfile(String id);
Observable<FacebookProfile> getFacebookProfile(String id);
60
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Demo:
Get List of RxJava Operators
Demo source
Compose Non-Blocking Service Layer
Demo source
61
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
flatMap?!
62
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
From map to flatMap
• map is used to apply a function to each element
• Function<T, R>
• The function could return a new sequence
• Function<T, Observable<R>>
• In which case we go from one to many sequences
• flatMap merges (flattens) those back into one
• i.e. map + merge
63
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Learn Your Operators
• flatMap is essential composing non-blocking services
• scatter-gather, microservices
• Along with concatMap, merge, zip , and others
• Learn and experiment with operators
• Use decision tree for choosing operators on reactivex.io to learn
64
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Stream Types
• “Cold” source -- passive, subscriber can dictate rate
• e.g. file, database cursor
• usually “replayed from the top” per subscriber
• “Hot” source -- active, produce irrespective of subscribers
• e.g. mouse events, timer events
• cannot repeat
• Not always a clear distinction
• operators further change stream behavior
• e.g. merge hot + cold
65
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Stream Types & Back-Pressure
• Cold sources are well suited for reactive back-pressure
• i.e. support request(n)
• Hot sources cannot pause, need alternative flow control
• buffer, sample or drop
• Several operators exist
• onBackPressureBuffer, onBackPressureDrop
• buffer, window
• etc.
66
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
More on
Stream Composition
67
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
How Operators Work
• Each operator is a deferred declaration of work to be done
observable.map(...).filter(...).take(5)...
• No work is done until there is a subscriber
observable.map(...).filter(...).take(5).subscribe(...)
• Underlying this is the lift operator
68
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
How the lift Operator Works
• Accepts function for decorating Subscriber
• lift(Function<Subscriber<DOWN>, Subscriber<UP>>)
• Returns new Observable that when subscribed to will use the function to
decorate the Subscriber
• Effectively each operator decorates the target Subscriber
• at the time of subscribing
69
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
The Subscribe
• For every subscriber the lift chain is used (subscriber decorated)
• Data starts flowing to the subscriber
• Every subscriber is decorated independently
• Results in separate data pipelines (N subscribers → N pipelines)
70
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Reasons For Multiple Subscribers
• Different rates of consumption, slow/fast consumers
• Different resource needs, i.e. IO vs CPU bound
• Different tolerance to errors
• Different views on dealing with overflow
• Different code bases
71
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Shared Data Pipeline
• It’s possible to have shared pipeline across subscribers
• Insert shared publisher in the chain
• vs lift which decorates every subscriber
• Both RxJava and Reactor support this
• observable.share() and stream.process(...) respectively
• Reactor has processors for fan-out or point-to-point
• pass all elements to all subscribers
• distribute elements (“worker queue” pattern)
72
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Demo:
Multiple Streams,
Shared Streams (fan-out, point-to-point)
Demo Source
73
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• By default all work performed on subscriber’s thread
• Operators generally not concurrent
• some do accept rx.Scheduler (timer-related)
• Two operators for explicit concurrency control
• subscribeOn(Scheduler), observeOn(Scheduler)
• Schedulers class with factory methods for Scheduler instances
• io(), computation(), trampoline(), …
Concurrency in Rx
74
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Invoke rest of the chain of operators on specified Scheduler
• Inserts async boundary for downstream processing
• Uses a queue to buffer elements
• Temporarily mitigate different upstream/downstream rates
observeOn Operator
75
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Put source Observable on specified Scheduler
• both initial subscribe + subsequent requests
• Order in chain of operators not significant
• Use for Observable that performs blocking I/O
• e.g. observable.subscribeOn(Schedulers.io())
subscribeOn operator
76
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
• Reactive Streams Processor for explicit concurrency control
• comparable to Rx observeOn
Streams.period(1)
.process(RingBufferProcessor.create())
.consume(...);
• Processor can also insert async boundary for upstream signals
• comparable to Rx subscribeOn
• Internally some operators may use Timer thread
• the main reason for Rx operators accepting Scheduler
Concurrency in Reactor
77
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Error Handling
• try-catch-finally is of limited value in non-blocking app
• Exceptions may occur on different thread(s)
• Notifications are the only path to consistent error handling
• Reactive Streams forbids propagating exceptions through the call-stack
• Subscriber receives onError
78
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Try but won’t catch
try {
Streams.just(1, 2, 3, 4, 5)
.map(i -> {
throw new NullPointerException();
})
.consume(
element -> { … },
error -> logger.error("Oooh error!", error)
);
}
catch (Throwable ex) {
logger.error("Crickets...");
}
79
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Recovering from Errors
• There are operators to handle error notifications
• Swallow error + emit backup sequence (or single value)
• onErrorResumeNext, onErrorReturn
• Re-subscribe, it might work next time
• retry, retryWhen
• Lifecycle related
• doOnTerminate/finallyDo… before/after error-complete
80
Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 81
Follow-up talk on Thursday (10:30am)
“Reactive Web Applications”
Learn More. Stay Connected.
@springcentral Spring.io/video

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Reactive programming
Introduction to Reactive programmingIntroduction to Reactive programming
Introduction to Reactive programmingDwi Randy Herdinanto
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaJiangjie Qin
 
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018Scrum Breakfast Vietnam
 
Quarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java frameworkQuarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java frameworkSVDevOps
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1ScyllaDB
 
YOW2018 - Events and Commands: Developing Asynchronous Microservices
YOW2018 - Events and Commands: Developing Asynchronous MicroservicesYOW2018 - Events and Commands: Developing Asynchronous Microservices
YOW2018 - Events and Commands: Developing Asynchronous MicroservicesChris Richardson
 
HBase and HDFS: Understanding FileSystem Usage in HBase
HBase and HDFS: Understanding FileSystem Usage in HBaseHBase and HDFS: Understanding FileSystem Usage in HBase
HBase and HDFS: Understanding FileSystem Usage in HBaseenissoz
 
Deploying Confluent Platform for Production
Deploying Confluent Platform for ProductionDeploying Confluent Platform for Production
Deploying Confluent Platform for Productionconfluent
 
Getting Started with Confluent Schema Registry
Getting Started with Confluent Schema RegistryGetting Started with Confluent Schema Registry
Getting Started with Confluent Schema Registryconfluent
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsJonas Bonér
 
Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesBruno Borges
 
[Webinar]: Working with Reactive Spring
[Webinar]: Working with Reactive Spring[Webinar]: Working with Reactive Spring
[Webinar]: Working with Reactive SpringKnoldus Inc.
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBScyllaDB
 
Vert.x for Microservices Architecture
Vert.x for Microservices ArchitectureVert.x for Microservices Architecture
Vert.x for Microservices ArchitectureIdan Fridman
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examplesPeter Lawrey
 
Scylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScyllaDB
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka StreamsGuozhang Wang
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeperSaurav Haloi
 
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, ConfluentTemporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, ConfluentHostedbyConfluent
 

Was ist angesagt? (20)

Introduction to Reactive programming
Introduction to Reactive programmingIntroduction to Reactive programming
Introduction to Reactive programming
 
Producer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache KafkaProducer Performance Tuning for Apache Kafka
Producer Performance Tuning for Apache Kafka
 
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
 
Quarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java frameworkQuarkus - a next-generation Kubernetes Native Java framework
Quarkus - a next-generation Kubernetes Native Java framework
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
 
YOW2018 - Events and Commands: Developing Asynchronous Microservices
YOW2018 - Events and Commands: Developing Asynchronous MicroservicesYOW2018 - Events and Commands: Developing Asynchronous Microservices
YOW2018 - Events and Commands: Developing Asynchronous Microservices
 
HBase and HDFS: Understanding FileSystem Usage in HBase
HBase and HDFS: Understanding FileSystem Usage in HBaseHBase and HDFS: Understanding FileSystem Usage in HBase
HBase and HDFS: Understanding FileSystem Usage in HBase
 
Deploying Confluent Platform for Production
Deploying Confluent Platform for ProductionDeploying Confluent Platform for Production
Deploying Confluent Platform for Production
 
Getting Started with Confluent Schema Registry
Getting Started with Confluent Schema RegistryGetting Started with Confluent Schema Registry
Getting Started with Confluent Schema Registry
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 
Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
Quarkus k8s
Quarkus   k8sQuarkus   k8s
Quarkus k8s
 
[Webinar]: Working with Reactive Spring
[Webinar]: Working with Reactive Spring[Webinar]: Working with Reactive Spring
[Webinar]: Working with Reactive Spring
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDB
 
Vert.x for Microservices Architecture
Vert.x for Microservices ArchitectureVert.x for Microservices Architecture
Vert.x for Microservices Architecture
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Scylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with RaftScylla Summit 2022: Making Schema Changes Safe with Raft
Scylla Summit 2022: Making Schema Changes Safe with Raft
 
Introduction to Kafka Streams
Introduction to Kafka StreamsIntroduction to Kafka Streams
Introduction to Kafka Streams
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, ConfluentTemporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
Temporal-Joins in Kafka Streams and ksqlDB | Matthias Sax, Confluent
 

Andere mochten auch

Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaKasun Indrasiri
 
Introduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingIntroduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingEdward Amsden
 
Reactive Programming in Spring 5
Reactive Programming in Spring 5Reactive Programming in Spring 5
Reactive Programming in Spring 5poutsma
 
Functional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix APIFunctional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix APIC4Media
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & designallegro.tech
 
Reactive design: languages, and paradigms
Reactive design: languages, and paradigmsReactive design: languages, and paradigms
Reactive design: languages, and paradigmsDean Wampler
 
Functional Reactive Programming in Javascript
Functional Reactive Programming in JavascriptFunctional Reactive Programming in Javascript
Functional Reactive Programming in JavascriptBrian Lonsdorf
 
Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysManuel Bernhardt
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJSstefanmayer13
 
What I learned teaching programming to 150 beginners
What I learned teaching programming to 150 beginnersWhat I learned teaching programming to 150 beginners
What I learned teaching programming to 150 beginnersEtiene Dalcol
 
Improve the Development Process with DevOps Practices by Fedorov Vadim
Improve the Development Process with DevOps Practices by Fedorov VadimImprove the Development Process with DevOps Practices by Fedorov Vadim
Improve the Development Process with DevOps Practices by Fedorov VadimSoftServe
 
Becoming a Better Developer #WCA2
Becoming a Better Developer #WCA2Becoming a Better Developer #WCA2
Becoming a Better Developer #WCA2Brian Richards
 
Steve Rice: Travel Big in a Small Island - Puerto Rico
Steve Rice: Travel Big in a Small Island - Puerto RicoSteve Rice: Travel Big in a Small Island - Puerto Rico
Steve Rice: Travel Big in a Small Island - Puerto RicoSteve Rice Los Gatos
 
Bridging the Gap Between Data Science & Engineer: Building High-Performance T...
Bridging the Gap Between Data Science & Engineer: Building High-Performance T...Bridging the Gap Between Data Science & Engineer: Building High-Performance T...
Bridging the Gap Between Data Science & Engineer: Building High-Performance T...ryanorban
 
The Tester Role & Scrum
The Tester Role & ScrumThe Tester Role & Scrum
The Tester Role & ScrumJohan Hoberg
 
Booz Allen Field Guide to Data Science
Booz Allen Field Guide to Data Science Booz Allen Field Guide to Data Science
Booz Allen Field Guide to Data Science Booz Allen Hamilton
 

Andere mochten auch (20)

Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
Reactive Web Applications
Reactive Web ApplicationsReactive Web Applications
Reactive Web Applications
 
Reactive Spring Framework 5
Reactive Spring Framework 5Reactive Spring Framework 5
Reactive Spring Framework 5
 
Introduction to Functional Reactive Programming
Introduction to Functional Reactive ProgrammingIntroduction to Functional Reactive Programming
Introduction to Functional Reactive Programming
 
Reactive Programming in Spring 5
Reactive Programming in Spring 5Reactive Programming in Spring 5
Reactive Programming in Spring 5
 
Functional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix APIFunctional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix API
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & design
 
Reactive design: languages, and paradigms
Reactive design: languages, and paradigmsReactive design: languages, and paradigms
Reactive design: languages, and paradigms
 
Functional Reactive Programming in Javascript
Functional Reactive Programming in JavascriptFunctional Reactive Programming in Javascript
Functional Reactive Programming in Javascript
 
Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDays
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
Introduction to Reactive Java
Introduction to Reactive JavaIntroduction to Reactive Java
Introduction to Reactive Java
 
What I learned teaching programming to 150 beginners
What I learned teaching programming to 150 beginnersWhat I learned teaching programming to 150 beginners
What I learned teaching programming to 150 beginners
 
Improve the Development Process with DevOps Practices by Fedorov Vadim
Improve the Development Process with DevOps Practices by Fedorov VadimImprove the Development Process with DevOps Practices by Fedorov Vadim
Improve the Development Process with DevOps Practices by Fedorov Vadim
 
Becoming a Better Developer #WCA2
Becoming a Better Developer #WCA2Becoming a Better Developer #WCA2
Becoming a Better Developer #WCA2
 
Steve Rice: Travel Big in a Small Island - Puerto Rico
Steve Rice: Travel Big in a Small Island - Puerto RicoSteve Rice: Travel Big in a Small Island - Puerto Rico
Steve Rice: Travel Big in a Small Island - Puerto Rico
 
Bridging the Gap Between Data Science & Engineer: Building High-Performance T...
Bridging the Gap Between Data Science & Engineer: Building High-Performance T...Bridging the Gap Between Data Science & Engineer: Building High-Performance T...
Bridging the Gap Between Data Science & Engineer: Building High-Performance T...
 
The Programmer
The ProgrammerThe Programmer
The Programmer
 
The Tester Role & Scrum
The Tester Role & ScrumThe Tester Role & Scrum
The Tester Role & Scrum
 
Booz Allen Field Guide to Data Science
Booz Allen Field Guide to Data Science Booz Allen Field Guide to Data Science
Booz Allen Field Guide to Data Science
 

Ähnlich wie Intro to Reactive Programming

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
 
Migrating to Angular 5 for Spring Developers
Migrating to Angular 5 for Spring DevelopersMigrating to Angular 5 for Spring Developers
Migrating to Angular 5 for Spring DevelopersGunnar Hillert
 
Migrating to Angular 4 for Spring Developers
Migrating to Angular 4 for Spring Developers Migrating to Angular 4 for Spring Developers
Migrating to Angular 4 for Spring Developers VMware Tanzu
 
Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Daniel Woods
 
Cloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven MicroservicesCloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven MicroservicesVMware Tanzu
 
Crossing the CI/CD/DevOps Chasm
Crossing the CI/CD/DevOps ChasmCrossing the CI/CD/DevOps Chasm
Crossing the CI/CD/DevOps ChasmVMware Tanzu
 
IO State In Distributed API Architecture
IO State In Distributed API ArchitectureIO State In Distributed API Architecture
IO State In Distributed API ArchitectureOwen Rubel
 
SpringOnePlatform2017 recap
SpringOnePlatform2017 recapSpringOnePlatform2017 recap
SpringOnePlatform2017 recapminseok kim
 
Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs VMware Tanzu
 
Cloud Configuration Ecosystem at Intuit
Cloud Configuration Ecosystem at IntuitCloud Configuration Ecosystem at Intuit
Cloud Configuration Ecosystem at IntuitVMware Tanzu
 
The Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring CloudThe Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring CloudVMware Tanzu
 
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...cornelia davis
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Springsdeeg
 
Lattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring ApplicationsLattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring ApplicationsMatt Stine
 
Designing, Implementing, and Using Reactive APIs
Designing, Implementing, and Using Reactive APIsDesigning, Implementing, and Using Reactive APIs
Designing, Implementing, and Using Reactive APIsVMware Tanzu
 
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...VMware Tanzu
 
Securing Microservices with Spring Cloud Security
Securing Microservices with Spring Cloud SecuritySecuring Microservices with Spring Cloud Security
Securing Microservices with Spring Cloud SecurityWill Tran
 
State of Securing Restful APIs s12gx2015
State of Securing Restful APIs s12gx2015State of Securing Restful APIs s12gx2015
State of Securing Restful APIs s12gx2015robwinch
 
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...VMware Tanzu
 
Building .NET Microservices
Building .NET MicroservicesBuilding .NET Microservices
Building .NET MicroservicesVMware Tanzu
 

Ähnlich wie Intro to Reactive Programming (20)

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
 
Migrating to Angular 5 for Spring Developers
Migrating to Angular 5 for Spring DevelopersMigrating to Angular 5 for Spring Developers
Migrating to Angular 5 for Spring Developers
 
Migrating to Angular 4 for Spring Developers
Migrating to Angular 4 for Spring Developers Migrating to Angular 4 for Spring Developers
Migrating to Angular 4 for Spring Developers
 
Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015
 
Cloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven MicroservicesCloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven Microservices
 
Crossing the CI/CD/DevOps Chasm
Crossing the CI/CD/DevOps ChasmCrossing the CI/CD/DevOps Chasm
Crossing the CI/CD/DevOps Chasm
 
IO State In Distributed API Architecture
IO State In Distributed API ArchitectureIO State In Distributed API Architecture
IO State In Distributed API Architecture
 
SpringOnePlatform2017 recap
SpringOnePlatform2017 recapSpringOnePlatform2017 recap
SpringOnePlatform2017 recap
 
Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs Documenting RESTful APIs with Spring REST Docs
Documenting RESTful APIs with Spring REST Docs
 
Cloud Configuration Ecosystem at Intuit
Cloud Configuration Ecosystem at IntuitCloud Configuration Ecosystem at Intuit
Cloud Configuration Ecosystem at Intuit
 
The Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring CloudThe Beginner’s Guide To Spring Cloud
The Beginner’s Guide To Spring Cloud
 
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Spring
 
Lattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring ApplicationsLattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring Applications
 
Designing, Implementing, and Using Reactive APIs
Designing, Implementing, and Using Reactive APIsDesigning, Implementing, and Using Reactive APIs
Designing, Implementing, and Using Reactive APIs
 
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
Welcome to the Reactive Revolution:RSocket and Spring Cloud Gateway - Spencer...
 
Securing Microservices with Spring Cloud Security
Securing Microservices with Spring Cloud SecuritySecuring Microservices with Spring Cloud Security
Securing Microservices with Spring Cloud Security
 
State of Securing Restful APIs s12gx2015
State of Securing Restful APIs s12gx2015State of Securing Restful APIs s12gx2015
State of Securing Restful APIs s12gx2015
 
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
 
Building .NET Microservices
Building .NET MicroservicesBuilding .NET Microservices
Building .NET Microservices
 

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
 
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
 
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
 
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
 
Reactor spring one2gx_2013_0902-final
Reactor spring one2gx_2013_0902-finalReactor spring one2gx_2013_0902-final
Reactor spring one2gx_2013_0902-finalStéphane Maldini
 

Mehr von Stéphane Maldini (15)

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
 
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
 
Reactor grails realtime web devoxx 2013
Reactor grails realtime web   devoxx 2013Reactor grails realtime web   devoxx 2013
Reactor grails realtime web devoxx 2013
 
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
 
Ss2gx
Ss2gxSs2gx
Ss2gx
 
Reactor spring one2gx_2013_0902-final
Reactor spring one2gx_2013_0902-finalReactor spring one2gx_2013_0902-final
Reactor spring one2gx_2013_0902-final
 
Eventsggx
EventsggxEventsggx
Eventsggx
 

Kürzlich hochgeladen

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 

Kürzlich hochgeladen (20)

VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 

Intro to Reactive Programming

  • 1. SPRINGONE2GX WASHINGTON DC Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Intro To Reactive Programming Stephane Maldini Rossen Stoyanchev
  • 2. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ About the Speakers • Stephane Maldini • Reactor Project Lead • Reactive Streams Spec contributor • Rossen Stoyanchev • Spring Framework committer • Spring MVC • WebSocket messaging (STOMP, SockJS) 2
  • 3. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Motivation 3
  • 4. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Long Running Shift to Concurrency For 30 years computer performance driven by Moore's Law; from now on, it will be driven by Amdahl's Law. Moore's Law is delivering more cores but not faster cores. March 2006 4
  • 5. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Amdahl’s Law 5 Theoretical max speedup using multiple processors? Limited by the time needed for sequential processing.
  • 6. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Scale Up • Remember SOA ? EJB 1 ? • distributed components, then services • functional boundaries between system components • location transparent resources pooled • … but it didn’t do well • complex / expensive solutions • full-stack approach • overhead not factored in: latency failure tolerance • Ended up in hype failure mockeries and hacker news rants 6
  • 7. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Internet Scale • Social media became mainstream • massive scale • Background Processing and pooled resources regain interest • everything “write-heavy” -- candidate for async handling • e.g. a tweet • Push-based servers start to proliferate • async response handling (e.g. facebook messages) 7
  • 8. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Cloud Scale • “Cloud-ready” systems began to spread around 2012 • AWS, open-source PaaS democratization • Tech giants expose internal distributed stack • Twitter, Google, Netflix... • Tools to address core concerns of distributed systems • concurrency, service discovery, monitoring 8
  • 9. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Wait! Another traffic spike: IoT 9
  • 10. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Scale Out • There are limits to scale the monolith way • cost efficiency aside • Memory overuse • large thread pools, application footprint • CPU underuse • blocking I/O (DB, remote service) 10
  • 11. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Tales of Time and Space 11 • Massive scale requires higher efficiency • respect physical laws • speed of light dampens inter-service communication • Pooling resources simply not enough • need to coordinate, compose, orchestrate data flows • Non-blocking must be embraced fundamentally
  • 12. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Non-Blocking Architecture 12 • Non-blocking requires profound change • can’t write imperative code • can’t assume single thread of control (e.g. exception handling) • Must deal with async results • listener/callbacks become unwieldy with nested composition • Everything becomes an event stream • e.g. from Input/OutputStream to stream of events
  • 13. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive Programming 13
  • 14. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • “Reactive” is used broadly to define event-driven systems • UI events, network protocols • Now also entering the domain of application/business logic • Non-blocking event-driven architecture Generally speaking… 14
  • 15. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive Manifesto 15 • Reflects the emerging field of scalable, non-blocking applications • A hark back to other successful manifestos • Well articulated but very broad strokes • Defines qualities of reactive systems • For reactive programming we need concrete tools
  • 16. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive Programming in Context • To build reactive apps we need two essential building blocks • Contract for interop between non-blocking components • Reactive Streams spec • API for composing asynchronous programs • e.g. Reactive Extensions 16
  • 17. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Myths about “Reactive” • Async / concurrent == reactive ? • easy to end up with too many threads • fill up hand-off queue • Must be async to be reactive ? • nope but must be agnostic to source of concurrency • Reactive is the domain of specific programming languages ? • language features can help • e.g. JDK 8 lambda 17
  • 18. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive Streams Specification for the JVM 18
  • 19. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Specification Goals • Govern the exchange of data across async boundaries • Use back-pressure for flow control • Fast sources should not overwhelm slower consumers • Provide API types, TCK 19
  • 20. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • When publisher maintains higher rate for extended time • queues grow without bounds • Back-pressure allows a subscriber to control queue bounds • subscriber requests # of elements • publisher produces up to # of requested • If source can’t be controlled (e.g. mouse movement clock tick) • publisher may buffer or drop • must obey # of requested elements Back-Pressure 20
  • 21. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ public interface Publisher<T> { void subscribe(Subscriber<? super T> s); } 21 public interface Subscription { void request(long n); void cancel(); } public interface Subscriber<T> { void onSubscribe(Subscription s); void onNext(T t); void onError(Throwable t); void onComplete(); } All are void methods… one-way, message style public interface Processor<T R> extends Subscriber<T> Publisher<R> { } API Types
  • 22. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 22 onSubscribe onNext* (onError|onComplete)? Publisher Subscriber Subscription Reactive Streams API request(n) cancel()
  • 23. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 23 Reactive Streams: Message Passing
  • 24. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  • 25. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  • 26. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 26
  • 27. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 27
  • 28. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 28
  • 29. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 29
  • 30. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 30
  • 31. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 31
  • 32. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  • 33. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  • 34. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
  • 35. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • No concurrent calls from Publisher to Subscriber (1.3) or vice versa (2.7) • A Subscriber may perform work synchronously or asynchronously • either way must be non-blocking (2.2) • Upper bound on open recursion required (3.3) • onNext → request → onNext → … → StackOverflow • No exceptions can be raised except NPE for null input (1.9 2.13) • Publisher calls onError(Throwable) • Subscriber cancels subscription Spec Rules 35
  • 36. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What does request(n) mean? • N represents an element count • relative (byte chunks) more so than absolute (# of bytes) • Boundaries • Must be > 0 • Long.MAX_VALUE means unbounded read • So does overflow of N 36
  • 37. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • Request some receive all request more ... (“stop-and-wait”) • request signal equivalent to an ack • Pre-fill buffer of certain capacity (“pre-fetch”) • request again when buffer falls below some threshold • more in-flight data → more risk • Request using timer/scheduler facility (“poll”) • Adapt to network or processing latency (“dynamic”) • find and pick the best request size Request Strategies 37
  • 38. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo: Publisher & Subscriber, Back-pressure, TCK verification Demo source, TCK test 38
  • 39. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • Sync is explicitly allowed -- 2.2 3.2 3.10 3.11 • If Publisher/Subscriber are both sync → open recursion • not always an issue e.g. single item Publisher • The picture is different in a processing chain (vs. single Publisher-Subscriber) • async hand-off is likely needed at some stage • but not at every stage • Async is not the goal non-blocking is the overall objective Async vs Sync 39
  • 40. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Async vs Sync (continued) • Implementations are free to choose how to do this • As long as they comply with all the rules • Generally speaking the burden is on the Publisher • make async or sync calls as necessary • prevent open recursion • sequential signals • Subscribers can largely ignore such concerns 40
  • 41. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive Streams → JDK 9 Flow.java • No single best fluent async/parallel API in Java [1] • CompletableFuture/CompletionStage • continuation-style programming on futures • java.util.stream • multi-stage/parallel, “pull”-style operations on collections • No "push"-style API for items as they become available from active source Java “concurrency-interest” list: [1] initial announcement [2] why in the JDK? [3] recent update 41
  • 42. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ JDK 9 java.util.concurrent • java.util.concurrent.Flow • Flow.Publisher Flow.Subscriber Flow.Subscription ... • Flow.consume(...) and Flow.stream(...) • Tie-ins to CompletableFuture and java.util.Stream • SubmissionPublisher • turn any kind of source to Publisher • Executor-based delivery to subscribers w/ bounded (ring) buffer • submit and offer strategies (block or drop) to publish 42
  • 43. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ API For Async Composition 43
  • 44. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 44 Application
  • 45. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 45 Application Reactive Streams HTTP Data Broker
  • 46. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 46 Application Reactive Streams HTTP Data Broker ? API to compose asynchronous programs?
  • 47. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Working with Streams • Non-blocking services return Publisher<T> instead of <T> • How do you attach further processing? • Reactive Streams is a callback-based API • becomes very nested quickly • Need something more declarative • it’s beyond the scope of Reactive Streams 47
  • 48. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • Publisher represents a stream of data • It’s natural to apply operations functional-style • like the Java 8 Stream • Need API for composing async logic • rise above callbacks Stream Operations 48
  • 49. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactor Stream • Project Reactor provides a Stream API • Reactive Streams Publisher + composable operations 49 Streams.just('a' 'b' 'c') .take(2) .map(Character::toUpperCase) .consume(System.out::println);
  • 50. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo: Reactor Stream, Back-Pressure Demo source 50
  • 51. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive Extensions (Rx) • Stream composition API based on Observer pattern • Originated at Microsoft, work by Erik Meijer • Implemented for different languages -- RxJava, RxJS, Rx.NET, … 51 Observable.just('a', 'b', 'c') .take(2) .map(Character::toUpperCase) .subscribe(System.out::println);
  • 52. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ RxJava and Reactive Streams • RxJava 1.x predates Reactive Streams and doesn’t implement it directly • Very similar concepts, different names • Observable-Observer vs Publisher-Subscriber • RxJava supports “reactive pull” back-pressure • RxJava 1.x - Reactive Streams bridge 52
  • 53. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • Java 8 Streams best suited for collections • Observer and Iterator actually very closely related • same except push vs pull • Observable however can represent any source including collections • RxJava 2 is planned to support Java 8 Stream • Observable.from(Iterable) + implement java.util.Stream Rx vs Java 8 Streams 53
  • 54. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo: RxJava, Back-Pressure, Reactive Streams Bridge Demo class, TCK test 54
  • 55. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ RxJava vs Reactor • RxJava is a great choice for composition in applications • many operators, polyglot (client/server), well-documented • Reactive Streams is ideal for use in library APIs • remain agnostic to composition • Reactor is positioned as foundation for libraries • essential Reactive Streams infrastructure + core operators • also used in high volume applications 55
  • 56. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Head Start with Stream Composition 56
  • 57. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Operators: reactivex.io Alphabetical List Aggregate, All, Amb, and_, And, Any, apply, as_blocking, AsObservable, AssertEqual, asyncAction, asyncFunc, Average, averageDouble, averageFloat, averageInteger, averageLong, blocking, Buffer, bufferWithCount, bufferWithTime, bufferWithTimeOrCount, byLine, cache, case, Cast, Catch, catchException, collect, collect (RxScala version of Filter), CombineLatest, combineLatestWith, Concat, concat_all, concatMap, concatMapObserver, concatAll, concatWith, Connect, connect_forever, cons, Contains, controlled, Count, countLong, Create, cycle, Debounce, decode, DefaultIfEmpty, Defer, deferFuture, Delay, delaySubscription, delayWithSelector, Dematerialize, Distinct, DistinctUntilChanged, Do, doAction, doOnCompleted, doOnEach, doOnError, doOnRequest, doOnSubscribe, doOnTerminate, doOnUnsubscribe, doseq, doWhile, drop, dropRight, dropUntil, dropWhile, ElementAt, ElementAtOrDefault, Empty, empty?, encode, ensures, error, every, exclusive, exists, expand, failWith, Filter, filterNot, Finally, finallyAction, finallyDo, find, findIndex, First, FirstOrDefault, firstOrElse, FlatMap, flatMapFirst, flatMapIterable, flatMapIterableWith, flatMapLatest, flatMapObserver, flatMapWith, flatMapWithMaxConcurrent, flat_map_with_index, flatten, flattenDelayError, foldl, foldLeft, for, forall, ForEach, forEachFuture, forIn, forkJoin, From, fromAction, fromArray, FromAsyncPattern, fromCallable, fromCallback, FromEvent, FromEventPattern, fromFunc0, from_future, from_iterable, from_list, fromNodeCallback, fromPromise, fromRunnable, Generate, generateWithAbsoluteTime, generateWithRelativeTime, generator, GetEnumerator, getIterator, GroupBy, GroupByUntil, GroupJoin, head, headOption, headOrElse, if, ifThen, IgnoreElements, indexOf, interleave, interpose, Interval, into, isEmpty, items, Join, join (string), jortSort, jortSortUntil, Just, keep, keep-indexed, Last, lastOption, LastOrDefault, lastOrElse, Latest, latest (Rx.rb version of Switch), length, let, letBind, limit, LongCount, ManySelect, Map, map (RxClojure version of Zip), MapCat, mapCat (RxClojure version of Zip), map-indexed, map_with_index, Materialize, Max, MaxBy, Merge, mergeAll, merge_concurrent, mergeDelayError, mergeObservable, mergeWith, Min, MinBy, MostRecent, Multicast, nest, Never, Next, Next (BlockingObservable version), none, nonEmpty, nth, ObserveOn, ObserveOnDispatcher, observeSingleOn, of, of_array, ofArrayChanges, of_enumerable, of_enumerator, ofObjectChanges, OfType, ofWithScheduler, onBackpressureBlock, onBackpressureBuffer, onBackpressureDrop, OnErrorResumeNext, onErrorReturn, onExceptionResumeNext, orElse, pairs, pairwise, partition, partition-all, pausable, pausableBuffered, pluck, product, Publish, PublishLast, publish_synchronized, publishValue, raise_error, Range, Reduce, reductions, RefCount, Repeat, repeat_infinitely, repeatWhen, Replay, rescue_error, rest, Retry, retry_infinitely, retryWhen, Return, returnElement, returnValue, runAsync, Sample, Scan, scope, Select (alternate name of Map), select (alternate name of Filter), selectConcat, selectConcatObserver, SelectMany, selectManyObserver, select_switch, selectSwitch, selectSwitchFirst, selectWithMaxConcurrent, select_with_index, seq, SequenceEqual, sequence_eql?, SequenceEqualWith, Serialize, share, shareReplay, shareValue, Single, SingleOrDefault, singleOption, singleOrElse, size, Skip, SkipLast, skipLastWithTime, SkipUntil, skipUntilWithTime, SkipWhile, skip_while_with_index, skip_with_time, slice, sliding, slidingBuffer, some, sort, sort-by, sorted-list-by, split, split-with, Start, startAsync, startFuture, StartWith, stringConcat, stopAndWait, subscribe, SubscribeOn, SubscribeOnDispatcher, subscribeOnCompleted, subscribeOnError, subscribeOnNext, Sum, sumDouble, sumFloat, sumInteger, sumLong, Switch, switchCase, switchIfEmpty, switchLatest, switchMap, switchOnNext, Synchronize, Take, take_with_time, takeFirst, TakeLast, takeLastBuffer, takeLastBufferWithTime, takeLastWithTime, takeRight (see also: TakeLast), TakeUntil, takeUntilWithTime, TakeWhile, take_while_with_index, tail, tap, tapOnCompleted, tapOnError, tapOnNext, Then, thenDo, Throttle, throttleFirst, throttleLast, throttleWithSelector, throttleWithTimeout, Throw, throwError, throwException, TimeInterval, Timeout, timeoutWithSelector, Timer, Timestamp, To, to_a, ToArray, ToAsync, toBlocking, toBuffer, to_dict, ToDictionary, ToEnumerable, ToEvent, ToEventPattern, ToFuture, to_h, toIndexedSeq, toIterable, toIterator, ToList, ToLookup, toMap, toMultiMap, ToObservable, toSet, toSortedList, toStream, ToTask, toTraversable, toVector, tumbling, tumblingBuffer, unsubscribeOn, Using, When, Where, while, whileDo, Window, windowWithCount, windowWithTime, windowWithTimeOrCount, windowed, withFilter, withLatestFrom, Zip, zipArray, zipWith, zipWithIndex 57
  • 58. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Operators: rx.Observable all, amb, ambWith, asObservable, buffer, cache, cast, collect, combineLatest, compose, concat, concatMap, concatWith, contains, count, countLong, create, debounce, defaultIfEmpty, defer, delay, delaySubscription, dematerialize, distinct, distinctUntilChanged, doOnCompleted, doOnEach, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnTerminate, doOnUnsubscribe, elementAt, elementAtOrDefault, empty, error, exists, filter, finallyDo, first, firstOrDefault, flatMap, flatMapIterable, from, groupBy, groupJoin, ignoreElements, interval, isEmpty, join, just, last, lastOrDefault, lift, limit, map, materialize, merge, mergeDelayError, mergeWith, nest, never, observeOn, ofType, onBackpressureBlock, onBackpressureBuffer, onBackpressureDrop, onBackpressureLatest, onErrorResumeNext, onErrorReturn, onExceptionResumeNext, publish, range, reduce, repeat, repeatWhen, replay, retry, retryWhen, sample, scan, sequenceEqual, serialize, share, single, singleOrDefault, skip, skipLast, skipUntil, skipWhile, startWith, subscribeOn, switchIfEmpty, switchMap, switchOnNext, take, takeFirst, takeLast, takeLastBuffer, takeUntil, takeWhile, throttleFirst, throttleLast, throttleWithTimeout, timeInterval, timeout, timer, timestamp, toList, toMap, toMultimap, toSortedList, unsubscribeOn, using, window, withLatestFrom, zip, zipWith 58
  • 59. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Operators: what can you do with sequences? • Originate -- fixed values, arrays, ranges, from scratch • Reduce -- filter, accumulate, aggregate, partition • Transform -- create new type of sequence • Combine -- concatenate, merge, pair • Control -- overflow, errors 59
  • 60. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Compose Non-blocking Service Layer Blocking: List<String> findUsers(String skill); LinkedInProfile getConnections(String id); TwitterProfile getTwitterProfile(String id); FacebookProfile getFacebookProfile(String id); Non-Blocking: Observable<String> findUsers(String skill); Observable<LinkedInProfile> getConnections(String id); Observable<TwitterProfile> getTwitterProfile(String id); Observable<FacebookProfile> getFacebookProfile(String id); 60
  • 61. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo: Get List of RxJava Operators Demo source Compose Non-Blocking Service Layer Demo source 61
  • 62. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ flatMap?! 62
  • 63. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ From map to flatMap • map is used to apply a function to each element • Function<T, R> • The function could return a new sequence • Function<T, Observable<R>> • In which case we go from one to many sequences • flatMap merges (flattens) those back into one • i.e. map + merge 63
  • 64. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Learn Your Operators • flatMap is essential composing non-blocking services • scatter-gather, microservices • Along with concatMap, merge, zip , and others • Learn and experiment with operators • Use decision tree for choosing operators on reactivex.io to learn 64
  • 65. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Stream Types • “Cold” source -- passive, subscriber can dictate rate • e.g. file, database cursor • usually “replayed from the top” per subscriber • “Hot” source -- active, produce irrespective of subscribers • e.g. mouse events, timer events • cannot repeat • Not always a clear distinction • operators further change stream behavior • e.g. merge hot + cold 65
  • 66. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Stream Types & Back-Pressure • Cold sources are well suited for reactive back-pressure • i.e. support request(n) • Hot sources cannot pause, need alternative flow control • buffer, sample or drop • Several operators exist • onBackPressureBuffer, onBackPressureDrop • buffer, window • etc. 66
  • 67. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ More on Stream Composition 67
  • 68. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ How Operators Work • Each operator is a deferred declaration of work to be done observable.map(...).filter(...).take(5)... • No work is done until there is a subscriber observable.map(...).filter(...).take(5).subscribe(...) • Underlying this is the lift operator 68
  • 69. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ How the lift Operator Works • Accepts function for decorating Subscriber • lift(Function<Subscriber<DOWN>, Subscriber<UP>>) • Returns new Observable that when subscribed to will use the function to decorate the Subscriber • Effectively each operator decorates the target Subscriber • at the time of subscribing 69
  • 70. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ The Subscribe • For every subscriber the lift chain is used (subscriber decorated) • Data starts flowing to the subscriber • Every subscriber is decorated independently • Results in separate data pipelines (N subscribers → N pipelines) 70
  • 71. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reasons For Multiple Subscribers • Different rates of consumption, slow/fast consumers • Different resource needs, i.e. IO vs CPU bound • Different tolerance to errors • Different views on dealing with overflow • Different code bases 71
  • 72. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Shared Data Pipeline • It’s possible to have shared pipeline across subscribers • Insert shared publisher in the chain • vs lift which decorates every subscriber • Both RxJava and Reactor support this • observable.share() and stream.process(...) respectively • Reactor has processors for fan-out or point-to-point • pass all elements to all subscribers • distribute elements (“worker queue” pattern) 72
  • 73. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo: Multiple Streams, Shared Streams (fan-out, point-to-point) Demo Source 73
  • 74. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • By default all work performed on subscriber’s thread • Operators generally not concurrent • some do accept rx.Scheduler (timer-related) • Two operators for explicit concurrency control • subscribeOn(Scheduler), observeOn(Scheduler) • Schedulers class with factory methods for Scheduler instances • io(), computation(), trampoline(), … Concurrency in Rx 74
  • 75. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • Invoke rest of the chain of operators on specified Scheduler • Inserts async boundary for downstream processing • Uses a queue to buffer elements • Temporarily mitigate different upstream/downstream rates observeOn Operator 75
  • 76. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • Put source Observable on specified Scheduler • both initial subscribe + subsequent requests • Order in chain of operators not significant • Use for Observable that performs blocking I/O • e.g. observable.subscribeOn(Schedulers.io()) subscribeOn operator 76
  • 77. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ • Reactive Streams Processor for explicit concurrency control • comparable to Rx observeOn Streams.period(1) .process(RingBufferProcessor.create()) .consume(...); • Processor can also insert async boundary for upstream signals • comparable to Rx subscribeOn • Internally some operators may use Timer thread • the main reason for Rx operators accepting Scheduler Concurrency in Reactor 77
  • 78. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Error Handling • try-catch-finally is of limited value in non-blocking app • Exceptions may occur on different thread(s) • Notifications are the only path to consistent error handling • Reactive Streams forbids propagating exceptions through the call-stack • Subscriber receives onError 78
  • 79. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Try but won’t catch try { Streams.just(1, 2, 3, 4, 5) .map(i -> { throw new NullPointerException(); }) .consume( element -> { … }, error -> logger.error("Oooh error!", error) ); } catch (Throwable ex) { logger.error("Crickets..."); } 79
  • 80. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Recovering from Errors • There are operators to handle error notifications • Swallow error + emit backup sequence (or single value) • onErrorResumeNext, onErrorReturn • Re-subscribe, it might work next time • retry, retryWhen • Lifecycle related • doOnTerminate/finallyDo… before/after error-complete 80
  • 81. Unless otherwise indicated these slides are © 2013-2014 Pivotal Software Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 81 Follow-up talk on Thursday (10:30am) “Reactive Web Applications” Learn More. Stay Connected. @springcentral Spring.io/video