Skip to content
Advertisement

How to configure separately both consumer and producer spring boot app when using rabbitmq?

I watched a tutorial that explains how to integrate RabbitMQ into Spring Boot app. In the tutorial, the ReceiveMessageHandler.java (Consumer) and SendMessageController.java (Producer) classes were in the same project. I want to implement them in two different Spring Boot application. However I can’t split the tutorial project into two consumer and producer project because of the ConfigureRabbitMq class. Because it is coupled both ReceiveMessageHandler.java (Consumer) and SendMessageController.java (Producer) classes.

How can I implement and configure two different cosnumer and producer Spring Boot application?

ConfigureRabbitMq.java

JavaScript

ReceiveMessageHandler.java (Consumer)

JavaScript

SendMessageController.java (Producer)

JavaScript

Advertisement

Answer

You need to configure RabbitMQ in both of the projects, however you DON’T need to create the following bean in Producer project’s ConfigureRabbitMq.class :

JavaScript
Advertisement