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
Sossenbinder
Sossenbinder5mo ago
Do you need a response right away? Or eventually?
blueberriesiftheywerecats
its rest api, so right away
Sossenbinder
Sossenbinder5mo ago
Then why would you send a message through a queue
blueberriesiftheywerecats
cuz Im not sure what would be the best way to connect api and service
Sossenbinder
Sossenbinder5mo ago
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
blueberriesiftheywerecats
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
Sossenbinder
Sossenbinder5mo ago
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
blueberriesiftheywerecats
is long polling about hanging client request for later? anyway I might better use grpc
Sossenbinder
Sossenbinder5mo ago
Sorry, just went for dinner. Long polling is keeping the request alive until data is available Of course there's also regular polling
HtmlCompiler
HtmlCompiler5mo ago
you are using an event bus to implement rpc 😐
Want results from more Discord servers?
Add your server