#yyds干货盘点#Project Reactor

Posted zhz小白

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了#yyds干货盘点#Project Reactor相关的知识,希望对你有一定的参考价值。

Operators - Publisher / Subscriber

  • Nothing Happens Until You subscribe()
  • Flux [ 0..N ] - onNext()、onComplete()、onError()
  • Mono [ 0..1 ] - onNext()、onComplete()、onError()

Backpressure

  • Subscription
  • onRequest()、onCancel()、onDispose()

线程调度 Schedulers

  • immediate() / single() / newSingle()
  • elastic() / parallel() / newParallel()

错误处理

  • onError / onErrorReturn / onErrorResume
  • doOnError / doFinally

1、pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zhz</groupId>
<artifactId>reactor-spring-bootsimple-reactor-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>reactor-spring-bootsimple-reactor-demo</name>
<description>Spring Boot集成reactor</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

2、测试代码

package com.zhz.reactor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Scheduler;
import reactor.#yyds干货盘点# python-redis-lock锁

#yyds干货盘点#动力节点王鹤Springboot教程笔记SpringBoot集成Dubbo

#yyds干货盘点#愚公系列2022年09月 微信小程序-WebGL画正方形

#yyds干货盘点#愚公系列2022年12月 微信小程序-WebGL立体图形的绘制

#yyds干货盘点#愚公系列2022年12月 微信小程序-WebGL纹理材质的使用

#yyds干货盘点#愚公系列2022年12月 微信小程序-WebGL画渐变色正方形