This document provides an overview of reactive applications and Reactive Streams. It discusses the need for reactive approaches to address increasing performance demands and microservices. Reactive applications are responsive, resilient, elastic and asynchronous. Reactive Streams provide a common abstraction for data streams and asynchronous data sources using an observer pattern. The document also summarizes several Reactive Streams implementations for the JVM like RxJava and frameworks like Spring WebFlux, Play and Vert.x that support reactive programming.
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
An introduction to Reactive applications, Reactive Streams, and options for the JVM (SACon SF 2016)
1. An introduction to reactive
applications, Reactive Streams, and
options for the JVM
Steve Pember
CTO, ThirdChannel
Software Architecture Con, 2016
THIRDCHANNEL @svpember
2. THIRDCHANNEL @svpember
Agenda
• The Problem
• To Be Reactive
• What are Reactive Streams?
• Rx in Depth
• An Overview of JVM Options
• Demo Time!
36. THIRDCHANNEL @svpember
• User Interface: What the user interacts with (JS, iOS, Android)
• Inter-Service: Distributed application topology + service
communication design (e.g. Kafka for async messaging)
• Intra-Service: The code! (well designed with bounded contexts)
• Framework: Structures your code + provides external
communication, DI, etc
• Execution Environment: Broad area, but includes how your
code is executed (e.g. in JVM: Tomcat, Jetty, Netty)
57. THIRDCHANNEL @svpember
What is Rx?
• Collections + Time
• A Single Abstraction over data from different sources
• Observer Pattern with Push-based iterators
• Stream Based Functional Programming
• … with Extensions for Reactive Programming
• Async is easy
• Backpressure
78. THIRDCHANNEL @svpember
Groovy
• Dynamic Language for the JVM
• Less Verbose (Reduce Java Boilerplate)
• Ruby/Python - esque Collections
• Run Time Meta Programming
• Optionally Typed
• AST Transformations
• Powerful Annotations
• Multi - Inheritance via Traits and @DelegatesTo
110. Don’t Unsubscribe from Observables
Programmatically complete them
when another Observable fires
111.
112. THIRDCHANNEL @svpember
AutoComplete Requirements
• Wait 250 ms between keypresses before querying
• If no keys are pressed, no query
• Successful queries should render movies
• Any new queries should kill in-flight queries
121. THIRDCHANNEL @svpember
RxJava 2.0
• Completely rebuilt for Reactive-Streams.org 1.0 spec
• Decreased resource usage
• No nulls allowed
• New Publisher types
122. THIRDCHANNEL @svpember
Publishers
• Observable - classic. In 2.0: no Backpressure
• Flowable - new to 2.0. Use this for Backpressure
• Single - only one item will be emitted or signal error
• Completable - only signal success or error
• Maybe - new to 2.0: one item emitted, signal success, or signal
error (think, Promise)
128. THIRDCHANNEL @svpember
ReactiveX JVM Family
• rxJava
• rxJavaFX
• rxGroovy
• rxClojure
• rxKotlin
• rxScala
• And many more (beyond JVM): https://github.com/ReactiveX
129. THIRDCHANNEL @svpember
Akka & Akka Streams
• Library
• Definition of Reactive System
• Created by LightBend
• Actor-Based Concurrency
• Implemented Streams on Top of Actor Model
143. THIRDCHANNEL @svpember
• High Performance Web Framework
• Non-Opinionated
• Non-Blocking Network Stack
• Built on Reactive Streams, Netty, Java 8, Guice
• Deterministic Asynchronous Execution
Take a Look at Ratpack
149. THIRDCHANNEL @svpember
Spring 5
• spring-web-reactive instead of spring-mvc
• Same @Controller programming model
• Different underlying API
• Based on Project Reactor
• Can run within Tomcat, Jetty, or Netty (e.g. can fallback to use
servlets)
150.
151. THIRDCHANNEL @svpember
Play Framework
• Part of the Lightbend family
• Built on Akka and Netty
• Async I/O
• Lightweight and stateless
• Encourages RESTful design
• Focus on JSON
152.
153. THIRDCHANNEL @svpember
Vert.X
• Event-driven & Non blocking
• lightweight, non-opinionated, and modular
• integrates with rxJava
• support for additional languages (like JS and Ruby)
• Can be used as a library embedded in an existing app