Hi Spring Team!

This feature introduces configuration-based initialization for multiple Rabbit brokers: - introduces the AutoConfiguration for MultiRabbit (contributed to spring-amqp #1111 & #1303 and available at version 2.3.5); - and provides documentation.

Javadocs are mentioning 2.4. I wonder if that's possible to be available in that version, but I will update it if eventually that's not the release version for this feature.

Comment From: wilkinsona

Thanks for the proposal. We have an open issue for auto-configuring multiple DataSources that is related to this. Unfortunately, I don't think we can add support for auto-configuring connections to multiple RabbitMQ brokers without considering how it will look for DataSources and other components.

You've taken a routing-based approach here that is akin to Spring Framework's AbstractRoutingDataSource. We also need to support the use case where users want multiple DataSource or ConnectionFactory beans in the context and things will need to be done in a way where one does not clash with the other.

On the DataSource side, we've seen more demand for auto-configuring multiple DataSources rather than a single AbstractRoutingDataSource and I suspect that will be the same for other backend services, including Rabbit brokers. In short, I think we'll need to do the design work for #15732 before we can consider this.

Comment From: rwanderc

Thank you @wilkinsona for the quick answer! Regarding the intention of having a matching design between multiple DataSources and ConnectionFactories, I can clearly see the benefit. But on the other hand, if that takes some more time (this issue #15732 is already 2 years old), blocking this feature might be less beneficial than updating the implementation later on. Don't you think it's worth it to carry on with the routing-based approach and update it when the decision is made?

Comment From: wilkinsona

No, I'm afraid not.

If it were only a matter of updating implementation details then it wouldn't be a problem, but I think it's almost certain that things would change from a user's perspective, and probably change considerably. That would mean that we're unable to do anything until Spring Boot 3.0 as the breaking changes would be too great to include in a minor release.

The benefit of adding multi-Rabbit auto-configuration now is that it makes it easier to do something that's already possible. The cost of adding multi-Rabbit auto-configuration now is that it may make it impossible to make some other enhancements until 3.0. Unfortunately, that cost outweighs the benefit.

Thanks very much for the pull request, but I think it's best that we close this one as we won't be able to merge it in its current form. As part of tackling #15732 we can consider how things would look for other backends including RabbitMQ. Right now I'm imagining properties for configuring multiple DataSources, ConnectionFactories, etc and with an additional property to group two or more of those into a routing DataSource or ConnectionFactory. As such, everything would be configured using spring.datasource.* or spring.rabbitmq rather than introduction completely separate groups of properties.