reactive()
端点
从 5.5 版本开始,ConsumerEndpointSpec
提供了一个 reactive()
配置属性,带有一个可选的定制器 Function<? super Flux<Message<?>>, ? extends Publisher<Message<?>>>
。此选项将目标端点配置为 ReactiveStreamsConsumer
实例,独立于输入通道类型,输入通道类型通过 IntegrationReactiveUtils.messageChannelToFlux()
转换为 Flux
。所提供的函数用于 Flux.transform()
操作符,以定制(publishOn()
、log()
、doOnNext()
等)来自输入通道的反应式流源。
以下示例演示了如何独立于最终订阅者和生产者将发布线程从输入通道更改为 DirectChannel
:
@Bean
public IntegrationFlow reactiveEndpointFlow() {
return IntegrationFlow
.from("inputChannel")
.transformWith(t -> t
.<String, Integer>transformer(Integer::parseInt)
.reactive(flux -> flux.publishOn(Schedulers.parallel()))
)
.get();
}
有关更多信息,请参阅 Reactive Streams 支持。