I am currently migrating our existing Spring asynchronous REST architecture to Spring's new WebFlux library and have a question around joining multiple requests so that they can listen for the same published response.
Use Case is as follows:
How can Client B subscribe to the same response stream that Client A is waiting for?
"Client A has subscribed and waits for a response" I suppose the request is coded as a Mono
and client A sibscribes to it literally:
Subscriber<Response> clientA = ... Mono<Response> request = makeRequest(...); request.subscribe(clientA);
then clientB should subscribe the same way:
Subscriber<Response> clientB = ... request.subscribe(clientB);
Moreover, the cache should contain not the previously saved response data, but the requests themselves, of type Mono<Response>
. Then, if such a request is found in the cache, new clients simply subscribe to it, regardless of was that request already completed or not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.