Presentation: Reactive Programming for Java Developers

Track: Innovations in Java and the Java Ecosystem

Location: Salon D

Day of week:

Slides: Download Slides

Level: Intermediate

Persona: Developer, Developer, JVM

What You’ll Learn

  • Understand what reactive programming is all about;
  • Make sense of the transition from traditional application development to reactive programming;
  • Dive into the details of reactive programming leveraging Java.

Abstract

The JDK 9 java.util.concurrent.Flow class implements features from the Reactive Streams spec that provide non-blocking concurrency by supporting "push" style operations for items from an active source as they become available. This is the tip of the iceberg on the quest for reactive programming and reactive style applications.

Starting with Doug Lea's own perspective on why it's important to have these contracts in the JDK and how they relate to other async/parallel APIs in the JDK such as CompletableFuture and java.util.Stream, we'll then look at the ecosystem of reactive libraries that has emerged around Reactive Streams from async composition libraries like RxJava to non-blocking versions of existing libraries like MonoDB, CouchBase, and others, and understand the reactive programming model they enable, why it matters, and how it changes they way you think about and write non-blocking application logic.

Question: 

How would you describe the persona of the target audience of this talk? Is it aimed at someone who is currently working with Spring MVC app? Will you be talking about the Reactor Project?

Answer: 
If you are a Spring developer, this is certainly an important talk if you want to understand one of the major things coming to Spring Framework 5.
The talk is based on our experiences in building a reactive web foundation for Spring MVC. If you think of Spring MVC as a Web application, or that it does many things that web applications need to do, many of the things that we go through now are the kinds of transitions that they are going to go through.
In fact this talk is really not about Spring at all. It is about gaining a pragmatic perspective on what reactive programming independent of Spring. It’s not so easy to relate to if you are coming from a more traditional background of type application development. It’s a big transition, and making sense of that transition, that this talk is really about.
Question: 

What would you say are the actionable benefits that a person is going to walk away with? What will they talk about, give back to their team, and be able to do right away?

Answer: 
Attendees will be able to go back and explain what the reactive streams specification is all about, as it is included Java 9 (the JDK Flow classes).
One of the first questions someone might have is how does it relate to the existing concurrent utilities that are in the JDK Java 8 and before that, including the stream API which we already have in Java.
Another natural question would be why we need something new in Java 9 when we already have this stream API? We already have CompletableFuture and other Reactive techniques in the JDK.
The talk starts from what we have, and shows why we need something more than what today in the JDK.
Attendees will also be able to talk to anybody about the role of reactive libraries, like RxJava or Reactor, and what that really means for the kinds of architectures they will be building. It’s really not something that someone can just start doing. It requires quite a bit of a ramp up. Their actionable item going back to their team is being prepared for that ramp up, and being able to put in context for others.
Question: 

What’s the motivation for your talk?

Answer: 
There is a major shift taking place in the industry as the types of architectures, or the types of applications that we build, have changed significantly since the first release of Servlets (back in 1997. Dramatic changes in what we do on the web and the kinds of clients that we serve and the kinds of traffic that we see.
There is a significant shift, with more distributed models for applications to serve clients and this is becoming more and more mainstream, dealing with large volumes of data.
While today it’s possible to handle that through more traditional means of horizontal scaling, what we are looking here is increasing the amount of efficiency for applications.
A new way of writing applications that requires to do more and to learn new things but ultimately, the payoff is better scalability and resilience for applications that can scale much better. It is a new paradigm.
Question: 

To what extent does the talk focus more on the mind shift of going reactive, as opposed to going into the details of how to get reactive?

Answer: 
This is not a high-level theoretical talk, it involves details of how to get reactive. It is a very concrete talk that starts by looking at asynchronous APIs: asking how do we design an asynchronous API?
If we assume that we want to be asynchronous, how do we do that in Java in a similar way to how Node.JS does it by default? They have a very specific constraint where they have only one thread so they need to make the most of it. The big question is how to replicate that experience in Java.
The talk goes from there, taking a very simple interface with representative things that you might return, and goes through that process and says "alright let’s use Java features.”
That’s not quite enough, so we use CompletionStage, a feature from Java 8. That gets us a little further, but it is still not enough and we can see why.
Then we say, all right, let’s generalize this as a stream, talk about stream processing and how such an abstraction can help just like with Java 8 streams, and then we go from there. We introduce rapid streams, and back pressure, and we talk about dealing with scale, queues and how we handle scale efficiently and effectively. From there, we talk about composition with our Java and reactor.
It’s really very incremental and very concrete all the way through. There is no theory in this.
Question: 

What is the next step for reactive programming? Are you diving into details that you’ll expose as someone working on Spring 5 and is deeply embedded with Rx issues and solutions?

Answer: 
That’s a good point. To be completely honest, we cover more than simply getting you to understand what this is about and what Reactor and RxJava do for you. Beyond that is the next step of thinking of the full stack, building an actual application, which means you need to go out and get data.
You need to go out, talk to NoSQL and all kinds of libraries for which the first question is often "is there a non-blocking reactive version of that library?"
We are going to be living in a world where you have blocking and non-blocking side by side. There are async drivers that are out there for JDBC (for data and MySQL). Some of them are already doing reactive stuff like MongoDB and CouchBase, but others have yet to come up with stuff. You can still build reactive applications, and there is a way to incorporate idle-latency type blocking operations into that.
Question: 

What do you feel is the most disruptive tech in IT right now?

Answer: 
Speaking strictly in terms of my talk, I see a transition taking place the likes of which I have only seen once in my 20+ year background in tech. And it is quite amazing.
We have a Java ecosystem that has been growing for just as long, and we have a certain way that we build web applications, based on a server container which, again, started out in 1997. There have been certain evolution points with the asynchronous HTTP requests, and also the non-blocking IO.
The point is that, back then, we accepted the server container and its threading model as an improvement over CGI, and we adopted that model, and it is only now that we are looking to disrupt this model.
I think this is a huge, huge change which is going to require pretty much re-writing, or at least significantly updating and providing parallel facilities in pretty much anything we use. Just about everything we use has some kind of blocking aspect to it. It is a huge, huge transition that I see, and one that is also going to require developers to change the way they do things.
But it is the only way achieve another level of scalability and resilience for applications.
Question: 

Do you have any recommendations for people who want to get a jumpstart to be better prepared for your talk?

Answer: 
https://github.com/reactor/lite-rx-api-hands-on (Self-Guided Tutorial of Reactor)
https://github.com/sdeleuze/spring-reactive-playground (Preview of a Spring 5 Reactive Web Style Application)
https://github.com/spring-projects/spring-reactive (Ongoing Development work for Spring 5)

Speaker: Rossen Stoyanchev

Spring Framework Committer @Pivotal

Rossen is a Spring Framework committer at Pivotal in NYC. He is deeply involved in the Spring 5 effort to enable reactive programming models starting with a reactive foundation for web applications and extending to data, messaging, and more.

Find Rossen Stoyanchev at

Similar Talks

Java Futures, 2019 Edition

Qcon

Java Language Architect @Oracle

Brian Goetz

Are We Really Cloud-Native?

Qcon

Director of Technology @Luminis_eu

Bert Ertman

The Trouble With Learning in Complex Systems

Qcon

Senior Cloud Advocate @Microsoft

Jason Hand

What Breaks Our Systems: A Taxonomy of Black Swans

Qcon

Site Reliability Engineer @Slack, Contributor to Seeking SRE, & SRECon Steering Committee

Laura Nolan