Avatar
1
anaconda875 Beginner
anaconda875 Beginner
Sync to Async http request and response architecture
We are developing a <strong>REST service</strong> (2) that act as a adapter between a blackbox <strong>Client</strong> (1) and blackbox <strong>Processor microservices</strong> (4). <p> </p> <p> (2) and (4) communicate with each other using <strong>Kafka</strong> (3) </p> <p> </p> <p> All components are stateless (except Kafka, right?) </p> <p> </p> <p> First, <strong>Client</strong> initial a command to <strong>REST service</strong> using http POST (sync), then <strong>REST service</strong> take this command and forward it to <strong>Processor ms</strong> (after doing some conversion) via <strong>Kafka</strong> (async). After this step, <strong>REST service</strong> will sleep (this http scope) and wait the result from <strong>Processor ms</strong> </p> <p> </p> <p> Then <strong>Processor ms</strong> handle this command and send the result back to <strong>REST service</strong> via <strong>Kafka</strong> (async). <strong>REST service</strong> wake up and and return the ResponseEntity to <strong>Client</strong> within same http scope. </p> <p> </p> <p> Now we decide to migrate (2) to microservice to take advantage of this architecture. And the problem occurred: instance 1 of (2) send command to (4), and (4) send the result to instance 2. But the http session is established between (1) and instance 1, and instance 2 cannot return to (1). This returning must be done by and only by instance 1. </p> <p> </p> <p> My first idea is, for example, let instance 1 be aware of the result from (4) no matter it was sent to which instance. But currently we have no solution to archive this idea. </p> <p> </p> <p> This is the diagram </p> <p> </p> <img class="content-img" src="https://stackask.com/wp-content/uploads/2022/12/Untitled.png" /> <p> </p> <p> We need a "non work-around" solution for this architecture. Please help. Thank you </p> <p> </p> <p> Note: we are unable to make change to blackbox components </p>
Answer