I have an API implemented with Jersey. An external service is making HTTP requests to my endpoint and expects a result into the response. Currently, I am using the Asynchronous Server API, in order to make all my business logic and then respond when ready. It’s working fine, but now I want to improve scalability and H/A.
My plan is to have multiple instances of my API behind an Nginx load balancer and all the requests accepted by any of my API instances will be forwarded to another microservice with RabbitMQ. Finally, I want to collect the results from the microservice and attach them into the response.
My question is if I can dynamically generate the response to the original HTTP request from any of my API instances. I want any of them, not only the one that originally got the webhook, to be able to send an HTTP response back to the caller. Somehow maybe to store/serialize the AsyncResponse object. In other words, this means that even if the instance that originally got the webhook request is stuck or down, another one can fill in and send the response.
Maybe this is not possible but still I would like to hear any other suggestions that can help.
Thanks.