I have a design question where we use REST and Kafka both.
eg.
UI -> Microservice-A -> publish to Kafka -> Microservice-B (does something) publish to Kafka -> Microservice-A (receives response from Microservice-B) -> Send response to UI
In above example UI is waiting for a response from Microservice-A while Microservice-A is not waiting for a response from Microservice-B as it’s asynchronous through Kafka.
How should we handle this? Do we immediately return to UI call with a response of “202 Accepted” as the processing may take longer while UI can poll again to check the response later?
Or should we use Websockets so that UI and Microservice-A connection remains open till we get the final response? Or use server-side events?
Any opinion or help would be greatly appreciated.