Don't wait for RPC response. Implementing RPC asynchronously? #4221
Unanswered
WilliamDEdwards
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following situation:
With the 'normal' RPC pattern, waiting for the result is blocking:
The RabbitMQ documentation says:
Instead of consuming messages on the callback queue right after publishing (blocking), I could return the
callback_queue
andcorrelation_id
immediately, and save it somewhere. When requesting the result, I would:callback_queue
andcorrelation_id
correlation_id
. To ensure that we don't wait for the results indefinitely, I'd setcall_later
on the Pika connection, like:So basically, I publish the message, but instead of waiting for the result, save the
callback_queue
andcorrelation_id
so that the client may retrieve the results at any time.Note: the callback queue is currently declared as
exclusive
, meaning only the original publisher connection may consume from it. In this case, separate Pika connections would consume from it, so I'd have to delete it myself after getting a result.Is this a generally accepted way to implement RPC asynchronously?
Beta Was this translation helpful? Give feedback.
All reactions