web api and service
I have api and service. api sends message through rabbitmq to service. the question is how do I get response from service and give it back to client through api?
10 Replies
Do you need a response right away? Or eventually?
its rest api, so right away
Then why would you send a message through a queue
cuz Im not sure what would be the best way to connect api and service
You can technically do semi synchronous behavior by immediately sending a reply event, but this problem is pretty much asking for a synchronous connection via http or rpc
can I use grpc for that? I have service that creates bot instances and web api that works as interface for client and I would like to give somehow client response about whether it was successful or not
It's an option, yeah. If you need responses immediately then an asynchronous style communication via a queue will not be the right tool, even if it could work for some time, it might be much slower with more traffic
There's also the option of asynchronous responses to a client via a websocket or long Polling, but that requires your api client to cooperate
is long polling about hanging client request for later?
anyway I might better use grpc
Sorry, just went for dinner. Long polling is keeping the request alive until data is available
Of course there's also regular polling
you are using an event bus to implement rpc 😐