Java编程方法论:响应式Spring Reactor 3设计与实现
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人

推荐序一

Towards a More Exciting, More Reactive Tomorrow

Hi, Spring fans!It's an interesting time to be alive. Today, the possible applications any programmer can build today are much more numerous than they were when I first started. The opportunities are so much more than they were before.It's possible to write code that runs on the server-side, on the backend, in giant systems, in big data platforms, in streaming platforms, on mobile phones, in cars, in the browser, on your watch, on your tablets, on your TVs, etc., all while using fairly similar languages, and while using similar skills. All of these destinations are also open and-often-open-source.It costs almost nothing to build this stuff.It takes time and it takes a computer with an internet connection.But, the tools are free. This is an ideal scenario.We can do almost anything today.I am very excited to see the opportunities expand in the last 20 years.

You know what I did not expect to happen so quickly?For the possibilities to become so good.I did not expect them to become so refined, so polished in so short a period of time.I was excited when Java ME came out.Now we have Android and iOS.I was excited when Hadoop came out.Now we have Spark and TensorFlow.I was excited when JDBC, the Servlet specification and Struts came out.Now we have Spring.I was excited when Netscape introduced JavaScript.Now we have Vue.js and React and Angular.I was excited when Spring came out.Now we have Spring Boot.I was excited when C++came out.Now we have Kotlin.I was excited when Ant came out.Now we have Maven and Gradle.I was excited when the ideas around continuous delivery started to crystalize.Now we have a Gitops-centric culture powered by technologies like Kubernetes.Everything has gotten so much better in the last 20 years. All of these things were exciting to me when they first arrived.But they're better now. They're easier. They're faster. They're cheaper. They're a natural evolution of the ideas we've known for a long time.

I feel the same enthusiasm—excitement—when I look at reactive code.I love Spring.I know that it's one of the most powerful ways to express my microservices. Today, I am excited about the opportunity to use Spring and Reactor to build much more resource-efficient, easier-to-understand, reactive services.

Reactive Programming is a natural next step in the creation of cloud native applications.Reactive libraries offer me several tentpole benefits.

I'll expand on those points here:

Reactive Programming offers one abstraction, no matter what the application (server-sent events, RSocket, WS, HTTP, Kafka, etc). A unified abstraction greatly simplifies the integration and composition of disparate services and data.

Reactive Programming supports more declarative, concise, deterministic ways to express complex, multithreaded algorithms.Remember:only one person TRULY understands how to write safe, concise multithreaded Java code... and it's NOT you!(It is not me, either!) I don't know who it is.It's better to let the library and framework do the dangerous work of managing concurrency.

Reactive Programming supports services that are more robust.Reactive libraries give us an API protocol to signal that our consumer is overwhelmed, or that it can not handle anymore.Libraries like Project Reactor provide operators to consistently handle errors, back-pressure, and more.The result is safer code with much fewer lines of code.

I believe that all new projects should embrace Reactive Programming, if possible.

So, when I saw that there is a book being written in Chinese to help people understand how to write reactive applications, I was very excited!I hope you'll take the opportunity to read this book, dear reader, and to learn how to work with Reactor and to see how it supports you when building reactive applications with Spring. The opportunities we have today are endless.We have the tools to build almost anything, easily, and to ship that software into production for very cheap. And I am excited to see what you will build with these tools.

Josh Long

Spring官方布道师

Java Champion成员

Kotlin GDE谷歌官方认证开发专家

San Francisco, USA

July 2020