Skip to content

Add support for RabbitMQ AMQP 1.0 #46608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

eddumelendez
Copy link
Contributor

@eddumelendez eddumelendez commented Jul 31, 2025

  • Add support for RabbitMQ AMQP 1.0
  • Add smoke test for RabbitMQ AMQP 1.0

@eddumelendez eddumelendez changed the title rabbitmq amqp Add support for Rabbitmq AMQP 1.0 Jul 31, 2025
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 31, 2025
Signed-off-by: Eddú Meléndez <[email protected]>
@eddumelendez eddumelendez changed the title Add support for Rabbitmq AMQP 1.0 Add support for RabbitMQ AMQP 1.0 Jul 31, 2025
private RabbitAmqpTemplate rabbitAmqpTemplate;

public void send(String message) {
this.rabbitAmqpTemplate.convertAndSend("foo", message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is foo/bar language OK with Spring Boot team?

* @author Eddú Meléndez
* @since 4.0.0
*/
@AutoConfiguration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think need to make before = RabbitAutoConfiguration.class and make that one conditional on something missing from this RabbitAmqpAutoConfiguration.
This is an addition to my previous point: the AMQP 1.0 is by default.
If we don't make them conditional on each other, then both protocols are going to be enabled and connected.
Especially, I worry about RabbitAmqpAdmin and RabbitAdmin which are going to handle topology in parallel but in different connections.
I don't think that we need to give a choice to be able to have both protocols in one Spring Boot application.


private final RabbitProperties properties;

RabbitAmqpAutoConfiguration(RabbitProperties properties) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to look into a separate RabbitAmqpProperties abstraction.
Even if some duplication is possible, a bunch of existing properties are not going to be used for AMQP 1.0 at all.
And might cause confusion.

Signed-off-by: Eddú Meléndez <[email protected]>
Signed-off-by: Eddú Meléndez <[email protected]>
Signed-off-by: Eddú Meléndez <[email protected]>
Signed-off-by: Eddú Meléndez <[email protected]>
Signed-off-by: Eddú Meléndez <[email protected]>
Signed-off-by: Eddú Meléndez <[email protected]>
* @since 4.0.0
*/
@AutoConfiguration
@ConditionalOnClass({ RabbitTemplate.class, Channel.class })
@ConditionalOnMissingClass({ "com.rabbitmq.client.amqp.Connection",
"org.springframework.amqp.rabbitmq.client.RabbitAmqpTemplate" })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct.
We may still have those classes on classpath, but opt-in to use AMQP 0.9.1.
For example, via auto-configuration exclusion for that our new RabbitAmqpAutoConfiguration.
Why not conditional on bean?

*/
@ExtendWith(OutputCaptureExtension.class)
class RabbitAutoConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(RabbitAutoConfiguration.class, SslAutoConfiguration.class))
.withClassLoader(new FilteredClassLoader("org.springframework.rabbit.stream")); // gh-38750
.withClassLoader(new FilteredClassLoader("org.springframework.rabbit.stream", "com.rabbitmq.client.amqp",
"org.springframework.amqp.rabbitmq.client")); // gh-38750
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a GH issue is relevant to your change.
Plus, I see you do the same in other place, but no GH issue number for whatsoever...

.withPropertyValues("management.metrics.use-global-registry=false");
.withPropertyValues("management.metrics.use-global-registry=false")
.withClassLoader(
new FilteredClassLoader("com.rabbitmq.client.amqp", "org.springframework.amqp.rabbitmq.client"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you make a RabbitAutoConfiguration conditional on bean from our new AMQP 1.0 auto-configuration, then we would not need this kind of classloader filtering.
Since we just don't include that RabbitAmqpAutoConfiguration into these existing tests.

id "org.springframework.boot.starter"
}

description = "Starter for using Spring AMQP and Rabbit MQ"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be more specific, e.g. : Starter for using Spring AMQP with Rabbit MQ over AMQP 0.9.1 protocol?

And probably something similar in existing started to emphasize that it is about AMQP 1.0 protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants