Multiple producers for one consumer or request

194 Views Asked by At

I can see that I can route one request to a responder and that there's different implementations like fireAndForget and all that but I have a case where producers are responsible for their subset of data. Specifically, the producers are actually just Kafka Consumers who are assigned a unique set of partition of the overall topic.

Is there a way to basically route the request to all these producers, and let the producer decide if they have something to send in response or not? A "findAllUsers()" request would need data from all of them, so all of them would need to contribute a portion of the response. Is this possible with Rsocket or does it only support 1:1 connections?

1

There are 1 best solutions below

0
On

Only peer to peer. I guess you want this.

// Create connections to all producers.
Flux<RSocket> rSockets = Flux.from(...)
Request request = ...
// Merge all results from producers.
Flux.merge(rSockets.flatMap(r -> r.requestStream(DefaultPayload.create(request...))))
.subscribe();