In this post we will build on returning Java Objects in RabbitMQ RPC by returning an Object List. What we'll do is extend our Reservation system by including a "?" command line option to retrieve a list of Customers. Here's what that would look like.
At the Server
Let's first look at returning the Customer Object List from the RabbitMQ Server process. We're creating a new Queue to handle this process, but other than that the only changes are in the mapping of the List Object in Jackson at (1).
Handling the List Object on the Client
I just mentioned the Jackson ObjectMapper as being the focus on creating the Customer object list. We'll see it as the star on the Client Side as well (1). Apart from the mapping change we're using our new RPC_LIST_QUEUE and changing the definition of our response object to a BlockingQueue<List<Customer>>.
A sidebar on Jackson is that its use here is absolutely no different than when receiving an Object List from a REST Endpoint. You'll see that in my post Retrieving REST Data Object Lists with Jersey and Jackson. Nice!
Source Code Notes for this Post
Source code discussed in our Bootique RabbitMQ Series is found in my NixMash Bootique RabbitMQ Demo on GitHub.