Implementing Spring Boot messaging
In an ideal case, all microservice interactions are expected to happen asynchronously using publish-subscribe semantics. Spring Boot provides a hassle-free mechanism to configure messaging solutions:
In this example, we will create a Spring Boot application with a sender and receiver, both connected though an external queue. Perform the following steps:
Note
The full source code of this example is available as the chapter2.bootmessaging
project in the code files of this book.
Create a new project using STS to demonstrate this capability. In this example, instead of selecting Web, select AMQP under I/O:
Rabbit MQ will also be needed for this example. Download and install the latest version of Rabbit MQ from https://www.rabbitmq.com/download.html.
Rabbit MQ 3.5.6 is used in this book.
Follow the installation steps documented on the site. Once ready, start the RabbitMQ server via the following command:
$./rabbitmq-server
Make the configuration changes to the
application...