I have read about RPC pattern from official docs, but examples are really simple. The client sends a message with reply_to and correlation_id properties, the server gets a message from the queue and resends it to the client binding the same correlation_id.
My questions are:
1) What if the server is turn off, how client will get response
2) How to set timeout for RPC in client side
3) If the server is broken and threw an exception, should we send this exception to client
I will be grateful for any answer.
It is good practice to server to ack'ing RPC calls. Something like this described in RabbitMQ docs (in Python section):
Although unlikely, it is possible that the RPC server will die just after sending us the answer, but before sending an acknowledgment message for the request. If that happens, the restarted RPC server will process the request again. That's why on the client we must handle the duplicate responses gracefully, and the RPC should ideally be idempotent.
You can set TTL for message or entire queue: https://www.rabbitmq.com/ttl.html
It depends. If a request is idempotent than it is ok to not acknowledge message - another worker will process it. But it can become a poison pill: such requests will fill up your RPC queue and will cause DoS. So you can handle it manually for example with retry_count header (in case of failure worker re-queue message with decremented counter)