13. Ladies and Gentlemen, tonight's speaker...
19:00
Infinite Streams, Hot Fluxes, Live Queries,
and Tail-able Cursors
~ 20:00
Refreshments
20:30
Look, no HTTP! @bmatthews68
16. Ladies and Gentlemen, tonight's speaker...
19:00
Infinite Streams, Hot Fluxes, Live Queries,
and Tail-able Cursors
~ 20:00
Refreshments
20:30
Look, no HTTP! @bmatthews68
18. Reactive
• Non-blocking (usually asynchronous)
• Event loop driven
• Back-pressure
• Declarative programming model
• Error propagation
• High efficiency
• Suitable for I/O bound workloads
19. Reactor & WebFlux
• WebFlux added to Spring 5
• Annotation driven
• Functional (WebFlux.fn)
• WebFlux built on top of Project Reactor
• Project Reactor implements Reactive Streams specification
20. Reactor
• Interoperable with RxJava 2
• Two publishers
• Mono<T> - zero or one element
• Flux<T> - zero or more elements
• Cold Flux
• Requires subscriber
• Replays data from start every time
• Hot Flux
• No subscriber required
• No historical data
22. NoSQL databases
• Spring Data currently ships with reactive data access support
for
• Cassandra (template & repositories)
• Couchbase (template & repositories)
• MongoDB (template & repositories)
• Redis (template only)
23. JDBC?
• JDBC is synchronous/blocking
• ADBA is asynchronous but not reactive
• Based on CompletableFuture<T>
• No back-pressure
• Java 9 Flow API
24. R2DBC
• Started as experimental project
• Supported databases
• H2
• Postgres
• SQL Server
• MySQL requires Kotlin runtime
• Definitely not ready for production
25. Live Queries
• Query returns available data but keeps the cursor open to stream
new additions
• So its just a Hot Flux
• Called a tail-able cursor in MongoDB
• But doesn’t work with an initially empty result set :(
• Cassandra and Couchbase just return a Flux<T> and its fine for
Server Sent Events
• Solution is to use an infinite stream with a timer to simulate a tail-
able cursor