cloudamqp / amqp-client.cr

An AMQP 0-9-1 client for Crystal
https://cloudamqp.github.io/amqp-client.cr/
MIT License
69 stars 10 forks source link

RPC example #25

Closed aabajyan closed 2 years ago

aabajyan commented 3 years ago

It would be great if there was an example of writing a remote procedure call with this library using Thread::Mutex and Thread::ConditionVariable. I attempted to do this, but I failed. So I used sleep instead, which works but I don't think is really the best way to do it.

My code so far: https://github.com/aabajyan/norminette.cr/blob/main/src/sender.cr RPC on RabbitMQ: https://www.rabbitmq.com/tutorials/tutorial-six-ruby.html

carlhoerberg commented 2 years ago

Is your Sender the RPC server or the RPC client?

carlhoerberg commented 2 years ago

modified your sender to be a RPC client: https://gist.github.com/carlhoerberg/4fcd7af4817e9ebf6774d42c5c33df0a

untested, but you get the idea, to use a correlation_id + Channel to get the responses

aabajyan commented 2 years ago

Hello, Thank you for your response! It looks good to me!