News / Technology / Top Stories /

Spring Framework 5 Adjusts to Microservices with a New Reactive Programming Model

4 Oct 2017 6:00am, by

Support for reactive programming in Spring Framework 5 introduces an alternative programming paradigm for users reaching the limits of systems built on a synchronous blocking stack.

Version 5 of the Spring project, released into general availability last week, supports the latest Java builds, including JDK 9 and the Java EE 8 API level (e.g. Servlet 4.0). It also integrates well with a range of Java supporting tools, including Reactor 3.1, JUnit 5, and the Kotlin language.

Spring Framework 5 also introduces a dedicated reactive web framework called Spring WebFlux, noted Jürgen Höller of Pivotal, co-founder of the Spring Framework open source project and project lead and release manager for the core framework, writing in a blog post.

It’s being offered as an alternative to traditional blocking style, though the project will continue to support both. The growing popularity of microservices — highly distributed, event-driven architectures — often leads to problems for applications exhibiting complex function/service interdependence and sequencing, and this release addresses this trend.

As Pieter Humphrey, Pivotal’s principal product marketing manager, explains it, with microservices, you can reach a point where the system just can’t process requests fast enough.

“If the front door of Netflix is your phone, but on the back end, there’s a complicated menagerie of services trying to serve you and five million people to watch TV on your phone, if that interconnected circus of microservices can’t process that volume of requests quickly enough, to the point where your phone or your browser times out, the service might as well be offline,” he said.

More Accessible, More Familiar

Various players in the reactive programming ecosystem, including Kaazing, Netflix, Pivotal, Red Hat, Twitter, and Lightbend (formerly Typesafe, parent of the Scala programming language) have collaborated on standard low-level reactive concepts called Reactive Streams that are now being used in JDK 9.

The overall effort is to make reactive programming more accessible and more familiar to programmers. Its similarity to Spring MVC  should shorten the learning curve.

It’s not for everybody, according to Humphrey.

“It’s hard programming. It’s difficult to bug and debug. It’s difficult to operate. It’s hard to learn for most developers because they spent the past 10 years or 20 years developing in an imperative blocking style…

“We’ve spent two years making it a little more approachable, a little more accessible for the average developer. It’s still tricky. But for people reaching the limits of synchronous distributed systems, it’s pretty important. … Just like microservices, there’s a benefit, but you’re incurring a high level of complexity.”

In a blog post, he lists drivers in addition to the move to microservices:

  • With streaming or real-time data, the need to consume events, which map nicely to messages, with high concurrency.
  • The need for resource availability at the high end,  achieved by decoupling network latency from request processing.
  • Functions-as-a-service.

Spring 5 also embraces functional programming and provides several building blocks that allow you to compose your applications. If you decide to define your router that way, rather than using annotations, it will detect that and configure the server accordingly, Stéphane Nicoll, software engineer at Pivotal, explained to JAXenter.

It’s a reactive web framework via Spring WebFlux in annotated or functional styles. WebFlux is built on Project Reactor 3.1. It supports RxJava 1.3  and 2.1, and it runs on Tomcat, Jetty, Netty, or Undertow. You can use it on your preferred reactive runtime with no code changes.

And it has been integrated with popular Java EE 8 APIs. The Framework supports Servlet 4.0 and Bean Validation 2.0, and JPA 2.2. It also works with, and the JSON Binding API, as an alternative to Jackson/Gson in Spring MVC. Spring Framework 5 works with the current releases of Tomcat, Jetty, and Wildfly.

You can read more about what’s new here, sign up for the Oct. 4 webinar or learn more in person at SpringOne Platform 2017 in San Francisco, California, Dec. 4-7.

Feature image via Pixabay.


A digest of the week’s most important stories & analyses.

View / Add Comments

Please stay on topic and be respectful of others. Review our Terms of Use.