Reactor RabbitMQ in your Reactive Spring Boot Application — Part 3

{getToc} $title={Table of Contents}

Reactor RabbitMQ in your Reactive Spring Boot Application — Part 3

Reactor RabbitMQ in Reactive Spring Boot Application Part 3



Sender Project Module Structure


Sender Project Module Structure



In this part 3: 

I working on setting sender properties port and implemented close connection in main application.


Sender Service Main Application Runner


Sender Main Application Runner


Defined Part in Sender Service Part

server:
  port: 9000

RabbitMQ 

It is a message broker: it accepts and forwards messages. You can think about it as a post office: when you put the mail that you want posting in a post box, you can be sure that the letter carrier will eventually deliver the mail to your recipient. In this analogy, RabbitMQ is a post box, a post office, and a letter carrier.



Message Broker

It is an intermediary computer program that applications and services use to exchange information with each other. It can be used to store, deliver and route messages. It is important to understand that it is an intermediary computer program. This means that it doesn’t know if the services are online or offline and doesn’t know how many recipients there are, but it still ensures that the recipients receive the messages.


Queue

The messages received from the producers will be kept in a message queue, and as soon as the consumers are ready to receive them, they will consume the messages. That is how the message broker ensures that the recipient receives a given message.



In router configuration

Every time a POST request is made to this service at “/”, it will forward the server request to the ProductOrderHandler class.


Router Function Service


To Run Application: 

- Firstly, 

before running the sender-service application make sure you have the RabbitMQ running in the background.
I need to run Docker service, and then build rabbitmq by using command line in rabbitmq command prompt.

# latest RabbitMQ 3.10.6
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.10.6-management

Build up RabbitMQ image on Docker





This means that the RabbitMQ will be listening on port 5672 and the management portal will be on 15672.

- Secondly, 

To make a POST request to the endpoint "/", I will be using Postman Tool in the application running demo.


Request Send message service via postman


Service sent message successfully in application log


sent message successfully in application log


Result


Now, Let's see in RabbitMQ message broker that's running in browser on localhost.
We've got 1 queue message which just sent from the Sender Service Application via Postman Tool.


Got 1 message queue from sender service application


That's it for the Sender Service. I hope you got an idea on how to do it.


Watch Full Video Tutorial of this part 3 here:





Previous Post Next Post