响应式编程,是一种编程规范。它不是具体的某种框架。简单介绍一下基于Java编程语言的响应式编程是什么。
关键词: Reactive 、rxjava、project reactor
RxJava库 是 响应式的一种Java实现:
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
<version>1.2.2</version>
<scope>runtime</scope>
</dependency>
后来,响应式被定义了一种规范reactive-streams,因此,rxjava提供了 rxjava中的实现 与 reactive-streams接口的适配:
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava-reactive-streams</artifactId>
<version>1.2.1</version>
<scope>compile</scope>
</dependency>
响应式规范reactive-streams接口定义:
pom依赖
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>1.0.4</version>
</dependency>
规范只是提供了一些接口。从提供的接口来看,实际就是一种 发布-订阅模式,或者是观察者模式。
Project Reactor 是 spring生态的一个重要组成部分:
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.3.17.RELEASE</version>
<scope>compile</scope>
</exclusions>
</dependency>
后面再遇到rxjava、reactor、reactive,就不再陌生了。从此开启新篇章。