Sergey Galkin
Sergey Galkin

Reputation: 179

Looking for elegant way of generation Reactor hot stream

I have Reactor hot stream which polls Redis using reactive Lettuce API:

Flux
                    .generate(sink -> sink.next(0))
                    .flatMap(
                            r -> pollingConnection
                                    .reactive()
                                    .brpop(pollingTimeout, queue)
                    ...
                    .subscribe(subscription);

Is there a way to do it without flatMap? Any async sinks?

Upvotes: 1

Views: 342

Answers (1)

Simon Baslé
Simon Baslé

Reputation: 28301

for regular non-blocking polling, I guess you would better off using Flux.interval rather than Flux.generate (which, combined to flatMap, will generate 256 immediate requests btw)

since the API seems to be based on a brpop Publisher, you don't have much choice but using flatMap if you want to trigger multiple pops.

Upvotes: 1

Related Questions