简体   繁体   English

助焊剂起死回生如何应对背压

[英]Flux from iterable how to handle back pressure

I need to handle back pressure in my flux, that receives as input a List of object. 我需要处理助焊剂中的背压,该背压接收一个对象列表作为输入。 The size of the list varies from few hundreds to some hundreds of thousand elements. 列表的大小从几百个到几十万个元素不等。 The actual code is: 实际的代码是:

Flux.fromIterable(alarms)
            .limitRate(parallelism)
            .parallel(parallelism)
            .runOn(Schedulers.elastic(), bufferSize)
            .doOnNext(reactiveHandleDataService::handleAlarm)
;

The parameter "limitRange" simply force to refuse a list over a certain size, thing that I don't want. 参数“ limitRange”只是强制拒绝超过一定大小的列表,这是我不想要的。 I need all the data received to be given to reactiveHandleDataService, I can't lose a message. 我需要将接收到的所有数据都提供给reactHandleDataService,我不会丢失任何消息。

How can I handle back pressure in this case? 在这种情况下如何处理背压? I did't find much example explaining well the problem, especially using an iterable as source. 我没有找到很多很好地说明问题的示例,尤其是使用可迭代的源。

I'm using Californium-SR3 as release of reactor and this is part of a spring boot application. 我正在使用Californium-SR3作为反应堆的发布版,这是Spring Boot应用程序的一部分。

is handleAlarm job to have backpressure if cant support to many data to send request for new data after processing 1. if you cant have backPressure to handleAlarm you can add delay 如果处理后无法支持许多数据以发送新数据请求,则是handleAlarm作业具有背压。如果无法处理,则可以添加延迟

Flux.fromIterable(alarms)
        .limitRate(parallelism)
        .delayElements(Duration.ofMillis(10))
        .doOnNext(reactiveHandleDataService::handleAlarm)
        .subscribeOn(Schedulars.elastic)

; ;

and if you want backpressure why you are running in parallel 如果您想要背压,为什么要并行运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM