Remote interface: Implement client side for RPC
ajblane opened this issue · comments
Currently, RabbitMQ C client only provides the RPC client example and not provides the RPC server example.
RPC server
Here are some samples:
- In the issue, "Add rpc_server example #394", there is a rpc-server implementation that only can run with some problems that are a invalid pointer when freeing and no acknowledge. We can fix these problems and implement dcurl workers based on this implementation.
RPC client
- Exclusive callback queues with TTL property
For the RPC client example, it declares a private queue (callback queue) with auto-delete that means the queue is deleted when all consumers have finished using it. However, one RPC client only has one private queue. Therefore, I will modify a private queue with auto-delete into a private queue with exclusive. See RabbitMQ the difference between exclusive and auto-delete to know them. Moreover, exclusive queues auto-delete when the consumer disconnects and we need to keep connection alive, so we need to use exclusive callback queues with TTL property to automatically delete callback queues. - Correlation id is not required
In addition, in the scenario of AttachToTangle API, there only is 0 or 1 result message in the callback queue of a AttachToTangle thread, so correlation id is not required. -
Channel management for multiple threads
It is very common to open a new channel per thread and not share channels between them, see "Channels", so we may require the channel management. Here is [a example of the implementation of channel management].(https://github.com/alanxz/SimpleAmqpClient/blob/master/src/ChannelImpl.cpp#L134) - AMQP connection management for multiple threads
For the alanxz-provided RabbitMQ C AMQP client library, it does not support that multiple threads execute multiple channels in an AMQP connection. Therefore, we instead should open an AMQP connection per thread, as refers to "Writing applications using librabbitmq".