In this post I'm going to demonstrate using RabbitMQ RPC with the Bootique RabbitMQ Module. You can find RabbitMQ RPC examples elsewhere like in the RabbitMQ Java Examples on GitHub, but here we're going to enjoy the Bootique approach. All code in this post can be found in my NixMash Bootique RabbitMQ Demo repo on GitHub. Previous Bootique RabbitMQ-related posts are listed in the project's README.md file.
RPC stands for Remote Procedure Calls, or getting data back from a RabbitMQ Queue as well as send it. Up to this point we've had a one-way conversation with RabbitMQ Queues.
In our RPC Demo we're using the familiar Reservation Object and will be checking-in a guest. We have two task options:
Here is an example of both. First on the Client Side where we send a guest name of bob and receive a Customer object. Then we send a Reservation object and receive an quick summary message about our guest.
Here is what the RabbitMQ Server receives, first a String followed by a Reservation object.
Below is our Client RPC method for the task of sending a Reservation object and receiving a Guest Summary message.
On the Server end of the Queue we initialize our RabbitMQ Connection and Channel in Bootique, then
Source code discussed in our Bootique RabbitMQ Series is found in my NixMash Bootique RabbitMQ Demo on GitHub.