0
votes

Is it possible to set an overflow strategy in Webflux, like one would do for any other Sink? See https://projectreactor.io/docs/core/release/api/reactor/core/publisher/FluxSink.OverflowStrategy.html

The default behaviour appears to be:

FluxSink.OverflowStrategy BUFFER Buffer all signals if the downstream can't keep up. Warning! This does unbounded buffering and may lead to OutOfMemoryError.

I was looking for a way to change this to DROP or ERROR: (see https://projectreactor.io/docs/core/release/api/reactor/core/publisher/FluxSink.OverflowStrategy.html)

1
WebFlow? dont really understand what you mean - Toerktumlare
typo sorry, WebFlux - gotch4
@YauhenBalykin that could be applied to the service calls inside the controller method. I was wondering if there's a way to set the behaviour at container level? - gotch4
How are you creating the sink, the default, for example, is ignore when using a flux processor. - 123

1 Answers

0
votes

If you are using Flux.create, to emit values, we can pass FluxSink.OverflowStrategy.DROP as an additional parameter.

If you use EmitterProcessor /Any processor, the sink method accepts the OverflowStrategy.

    EmitterProcessor<Object> emitterProcessor = EmitterProcessor.create();
    FluxSink<Object> sink = emitterProcessor.sink(FluxSink.OverflowStrategy.DROP);

    // you should use sink to publish values
    sink.next(obj);