# 5.Reactive库

spring-webflux依赖于反应堆核心，并在内部使用它来构成异步逻辑并提供Reactive Streams支持。通常，WebFlux API返回Flux或Mono（因为它们在内部使用），并且宽容地接受任何Reactive Streams Publisher实现作为输入。 Flux vs Mono的使用很重要，因为它有助于表达基数，例如，期望单个或多个异步值，并且对于决策（例如在编码或解码HTTP消息时）至关重要。

对于带注解的控制器，WebFlux透明地适应应用程序选择的反应式库。这是在ReactiveAdapterRegistry的帮助下完成的，该工具为反应性库和其他异步类型提供了可插入的支持。该注册表具有对RxJava和CompletableFuture的内置支持，但是您也可以注册其他注册表。

对于功能性API（例如功能性端点，WebClient等），WebFlux API的一般规则适用于-Flux和Mono作为返回值，而Reactive Streams Publisher作为输入。提供发布者（无论是自定义的还是来自其他反应性库的发布者）时，只能将其视为语义未知（0..N）的流。但是，如果知道语义，则可以用Flux或Mono.from（Publisher）包装它，而不用传递原始Publisher。

例如，给定的发布者不是Mono，Jackson JSON消息编写者需要多个值。如果媒体类型暗示无限流（例如application / json + stream），则将分别写入和刷新值。否则，值将缓冲到列表中并呈现为JSON数组。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flydean.com/spring-framework-documentation5/webreactive/5.reactive-libraries.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
