I have a cluster of micro services with an exposed search API serving a client app. I want to "stream" in real time the aggregated results of a complex search. The search will be kicked of by the client calling the search API which in turn adds a message to a queue. This will be picked up by an orchestrator service which will in turn make calls to 1 or many partner APIs.
My search API has a signalR hub which streams the results of the search in a way akin to this example. My question is what are some messaging strategies for delivering new elements from the orchestrator to the search API hub stream.
I have thought of two possibilities (there are undoubtedly many more)
- The orchestrator loads elements into a cache which is in turn polled by the Search API, and new elements added to the stream.
- The orchestrator adds elements to a response message queue, the Search API listens and adds new elemnents to the stream.
Which idea sounds more reasonably?
My idea was to have correlating ID for the search and response elements, making the cache implementation a bit simpler and potentially a bit easier to scale horizontally.
For the response queue, I'm not sure how you'd go about listening only for the items you want for this request / thread. Probably more of an implementation detail, I'm not sure.