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:
- Client A connects to our web server and requests data
- We hit our cache to check if we have the data there
- We don't, so we go and retrieve this data (Client A has subscribed and waits for a response)
- Client B connects to our web server and requests the same data (hits the same endpoint)
- We check the cache, data is still not there
- As we are already fetching this data for Client A we don't want to make another request, however, we also do not want to turn Client B away. Client B should be able to listen for the same information
How can Client B subscribe to the same response stream that Client A is waiting for?