Reactor 3.0
Versioning scheme: ERA.MAJOR.MINOR
Production ready, but had to be out before Spring Framework 5
Still room for evolution after plenty of feedback
Flux.range(1, 1000)
.flatMap(i -> reactiveHttpCall("/quote/"+i), 1)
.subscribe(this::handleBody);
With --------
J-j-jeez Rick, I like
this backpressure
stuff
1 http call
Practical static
extensions
Initial N
ullability
support
Slide 48
Slide 48 text
“Reactor has matured,
laying out the foundations
for frameworks and users
to integrate their context
into the Core .”
Enterprise Ready:
Hooks & Customization,
Matured API
Slide 49
Slide 49 text
Cross-Cutting Concerns
Slide 50
Slide 50 text
Scannable
Visit the hierarchy of operators
Scan at each step for Attributes...
… either upstream (parents()) or downstream
(actuals())
Slide 51
Slide 51 text
Tagging and Naming
give a chain of
operator a name
give a chain of
operator attributes
Slide 52
Slide 52 text
Tagging and Naming
Flux.range(1, 10)
.name("myRange")
.tag("createdBy", "rick");
Slide 53
Slide 53 text
Hooks
On last operator
instantiation before
subscribe
On every operator
instantiation
Hooks.onLastOperator(
Operators.lift(scannable ->
scannable.tags()
.anyMatch(t -> t.getT1()
.contains("createdBy")),
(scannable, subscriber) -> {
fooService.registerOwnedFlux(scannable);
return subscriber;
}));
Hooks
Once every stream... Only visit streams containing tag...
Notify some service with the stream reference
and return the operator subscriber
Slide 56
Slide 56 text
Possible Application: Metrics
E.g. tag a Flux with “METRICS” and a framework
could pick that up and add an operator that
increments counters/timers...
Slide 57
Slide 57 text
Improved Testing Support
Slide 58
Slide 58 text
reactor-test
StepVerifier to assert expectations on any
Publisher
TestPublisher to simulate a reactive source
PublisherProbe to check which path was
used in complex chains
Reactor-Addons
Extend Reactor Core API
Adapt Reactor to different execution contracts
https://github.com/reactor/reactor-addons
Slide 85
Slide 85 text
Retry Support
Factory methods that provide a fluent API to incrementally configure a Function
suitable for Flux.retryWhen.
(tip: use static import)
Retry.allBut(Class...)
Retry.any()
Retry.anyOf(Class...)
Retry.onlyIf(Predicate)
Slide 86
Slide 86 text
Retry Support
flux.retryWhen(allBut(BusinessException.class)
.retryMax(3)
.exponentialBackoff(Duration.ofMillis(100),
Duration.ofMillis(500))
.timeout(Duration.ofMillis(1500))
.jitter(Jitter.random())
.doOnRetry(this::retryCallback)
);
Slide 87
Slide 87 text
Math
Take a Flux and apply operations to its whole set
of elements using MathFlux static methods.
Mono sum = Flux.range(1, 10)
.as(MathFlux::sumLong);
Slide 88
Slide 88 text
Math (with kotlin)
Mono sum = Flux.range(1, 10)
.sumLong();
Slide 89
Slide 89 text
An opinionated abstraction that helps you store and lookup a
Mono or a Flux to/from a cache.
CacheMono will store the Mono value or completion as a
Signal.
CacheFlux will collect the elements and terminal event as a
List.
Both only work with finite sources.
Cache Support
Slide 90
Slide 90 text
Mono test =
CacheMono.lookup(reader(data), "foo")
.onCacheMissResume(() -> Mono.just(1L))
.andWriteWith(writer(data));
Reader and writer interfaces to adapt to any type of cache
implementation + out-of-the-box variant for Map.
Cache Support
Slide 91
Slide 91 text
Community Highlights
Slide 92
Slide 92 text
Spring Ecosystem
#1 user and source of feedback
Slide 93
Slide 93 text
No content
Slide 94
Slide 94 text
No content
Slide 95
Slide 95 text
Reactive talk with
Slide 96
Slide 96 text
No content
Slide 97
Slide 97 text
reactive-gRPC
https://github.com/salesforce/reactive-grpc
Integrates reactive programming with grpc-java
From --
Slide 98
Slide 98 text
Lettuce
http://lettuce.io
A Reactor-based reactive driver for Redis
Slide 99
Slide 99 text
Tech.io
https://tech.io/playgrounds/929/reactive-programming-with-reactor-3
A community-driven programming learning platform
Slide 100
Slide 100 text
CloudFoundry Java Client
https://github.com/cloudfoundry/cf-java-client
The official Java client for CloudFoundry API
Slide 101
Slide 101 text
https://github.com/reactor/reactor-scala-extensions
Idiomatic Scala for Reactor
Slide 102
Slide 102 text
Reactor
Tomorrow
Near-and-far Future
Slide 103
Slide 103 text
Near-and-far Future
Reactor
Tomorrow
Slide 104
Slide 104 text
Reactor
Tomorrow
Near-and-far future
Slide 105
Slide 105 text
2019
2020
2017
2018
the Road from Here
Slide 106
Slide 106 text
2017 First,
a patch release
Slide 107
Slide 107 text
3.1.3
3.1.0
September
October
November
December
3.1.1 3.1.2
Slide 108
Slide 108 text
3.1.3
3.1.0
September
October
November
December
3.1.1 3.1.2
limitRequest,
Kotlin extensions...
Slide 109
Slide 109 text
3.1.3
3.1.0
September
October
November
December
3.1.1 3.1.2
index,
blockOptional...
Slide 110
Slide 110 text
3.1.3
3.1.0
September
October
November
December
3.1.1 3.1.2
Mostly bugfixes...
Slide 111
Slide 111 text
2018
Themes for
Slide 112
Slide 112 text
Continue On Error
Slide 113
Slide 113 text
errors are
terminal
Slide 114
Slide 114 text
continue on
(transient)
errors?
Slide 115
Slide 115 text
Now
Flux.range(0, 3)
.flatMap(v -> Mono.just(v)
.map(i -> 100 / i)
.doOnError(...)
.onErrorResume(
Mono.empty()
)
);
processing that
can fail
your face when
you read this code
Slide 116
Slide 116 text
Tomorrow
Flux.range(0, 3)
.map(i -> 100 / i)
.errorStrategyContinue()
.filter(i -> 100 / i > 4);
this is not impacted
and can still fail
this is protected
by this
Slide 117
Slide 117 text
Observability & Traceability
Slide 118
Slide 118 text
Micrometer
“SLF4J for metrics”
Slide 119
Slide 119 text
Sleuth & Zipkin
Currently focusing on tracing WebFlux and WebClient
any guess as to why these are different?
flatMap
concatMap
Slide 120
Slide 120 text
reactor-netty
Slide 121
Slide 121 text
API iteration release : 0.8.x
Immutable server and client builders
Lifecycle and interceptor API (doOnRequest...)
Initial user guide
Beyond 0.8
HTTP 2 support
Plug-And-Play Metrics
Connection Pool improvements
Backpressure strategies
Slide 124
Slide 124 text
File I/O Addon?
Slide 125
Slide 125 text
Java 9
continuously improve support
Slide 126
Slide 126 text
Java 9
continuously improve support
RSocket
Slide 127
Slide 127 text
Exploring RSocket (rsocket.io)
Duplex flow-control support
Multi-transport and multi-language
Decoupled from any serialization
Contributors from Facebook