I'm trying to understand how to properly setup the Publisher for Netflix DGS Subscriptions. I have found two interesting examples: If the subscription model is "one subscriber per GraphQL subscription connection, i.e. websockets", conceptually, if feels like we need to use a ConnectableFlux from the Netflix to . But on the other hand, Spring-GraphQL is using Sinks.Many to . And I'm struggling finding documentation on the tradeoffs between the two. Both seem to manage backpressue, albeit with slightly more configurable options in Sinks.Many. And ConnectableFlux seems to manage subscribers more elegantly with refCount....maybe Sinks.Many does as well too. I can easily bridge the gap between both approaches like so: @Component public class SinkConfig { private final Sinks.Many<Review> sink; private final Flux<Review> reviewFlux; public SinkConfig() { Sinks.Many<Review> sinks = Sinks.many().multicast().onBackpressureBuffer(Queues.SMALL_BUFFER_SIZE, false); this.reviewFlux = sinks.asFlux().publish().refCount(1); this.sink = sinks; } //Only subscribe to reviews written by a particular user Publisher<Review> publisher(String input) { return reviewFlux.filterWhen(x -> Mono.fromCallable(() -> x.getUsername().equals(input))); } void emit(Review review) { sink.emitNext(review, Sinks.EmitFailureHandler.FAIL_FAST); } }The above example seems overly complicated when compared against the Spring and Netflix examples. And I'm looking for a configuration that would be best suited to manage 1000's of concurrent subscriptions that are filtering on usernames. Any help would be greatly appreciated! (责任编辑:) |