Search code examples
spring-bootspring-integrationspring-integration-dsl

Spring Integration between two message brokers


I am new to Spring-Integration.

My use case is:

Listen to a RabbitMQ queue/topic, get the message, process it, send it to other message broker (mostly it will be another RabbitMQ instance).

Expected load: 5000 messages/sec

In application.properties we can set configurations for one host.

How to use Spring Integration between two message brokers?

All the examples that i see are for one message broker. Any pointers to get started with two message brokers and Spring Integration.

Regards,

Mahesh


Solution

  • Since you mention an application.properties it sounds like you use Spring Boot with its auto-configuration feature. It is very important detail in your question because Spring Boot has opinion about auto-configuration and you really can have only one broker connection configuration auto-configured. If you would like to have an another similar in the same application, then you should forget that auto-configuration feature. You still can use the mentioned application.properties, but you have to manage them manually.

    Since you talk about a RabbitMQ connection, so you need to exclude RabbitAutoConfiguration and manage all the required beans manually:

    @SpringBootApplication(exclude = RabbitAutoConfiguration.class)
    

    You still can use the @EnableConfigurationProperties(RabbitProperties.class) on some your @Configuration class to be able to inject that RabbitProperties and populate respective CachingConnectionFactory. For the second broker you can introduce your own @ConfigurationProperties or just configure everything manually reading properties via @Value. See more info about manual connection factory configuration in Spring AMQP reference manual: https://docs.spring.io/spring-amqp/docs/2.2.1.RELEASE/reference/html/#connections