diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index a9a9f180775..204c2ab6b8b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -196,7 +196,7 @@ public class RabbitAutoConfiguration { .to(template::setReplyTimeout); map.from(properties::getExchange).to(template::setExchange); map.from(properties::getRoutingKey).to(template::setRoutingKey); - map.from(properties::getQueue).whenNonNull() + map.from(properties::getDefaultReceiveQueue).whenNonNull() .to(template::setDefaultReceiveQueue); return template; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index fd7fcdfaddf..becc1374de1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -24,6 +24,7 @@ import java.util.List; import org.springframework.amqp.core.AcknowledgeMode; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.DeprecatedConfigurationProperty; import org.springframework.boot.convert.DurationUnit; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -776,7 +777,7 @@ public class RabbitProperties { * Name of the default queue to receive messages from when none is specified * explicitly. */ - private String queue; + private String defaultReceiveQueue; public Retry getRetry() { return this.retry; @@ -822,12 +823,23 @@ public class RabbitProperties { this.routingKey = routingKey; } + public String getDefaultReceiveQueue() { + return this.defaultReceiveQueue; + } + + public void setDefaultReceiveQueue(String defaultReceiveQueue) { + this.defaultReceiveQueue = defaultReceiveQueue; + } + + @Deprecated + @DeprecatedConfigurationProperty(replacement = "spring.rabbitmq.template.default-receive-queue") public String getQueue() { - return this.queue; + return getDefaultReceiveQueue(); } + @Deprecated public void setQueue(String queue) { - this.queue = queue; + setDefaultReceiveQueue(queue); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index bd2ad7e9ffb..2ec1f3688d0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -321,6 +321,19 @@ public class RabbitAutoConfigurationTests { } @Test + public void testRabbitTemplateDefaultReceiveQueue() { + this.contextRunner.withUserConfiguration(TestConfiguration.class) + .withPropertyValues( + "spring.rabbitmq.template.default-receive-queue:default-queue") + .run((context) -> { + RabbitTemplate rabbitTemplate = context.getBean(RabbitTemplate.class); + assertThat(rabbitTemplate).hasFieldOrPropertyWithValue( + "defaultReceiveQueue", "default-queue"); + }); + } + + @Test + @Deprecated public void testRabbitTemplateDefaultQueue() { this.contextRunner.withUserConfiguration(TestConfiguration.class) .withPropertyValues("spring.rabbitmq.template.queue:default-queue") diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 03069eecd9e..1a1bf607e86 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1180,9 +1180,9 @@ content into your application. Rather, pick only the properties that you need. spring.rabbitmq.ssl.trust-store-type=JKS # Trust store type. spring.rabbitmq.ssl.validate-server-certificate=true # Whether to enable server side certificate validation. spring.rabbitmq.ssl.verify-hostname=true # Whether to enable hostname verification. + spring.rabbitmq.template.default-receive-queue= # Name of the default queue to receive messages from when none is specified explicitly. spring.rabbitmq.template.exchange= # Name of the default exchange to use for send operations. spring.rabbitmq.template.mandatory= # Whether to enable mandatory messages. - spring.rabbitmq.template.queue= # Name of the default queue to receive messages from when none is specified explicitly. spring.rabbitmq.template.receive-timeout= # Timeout for `receive()` operations. spring.rabbitmq.template.reply-timeout= # Timeout for `sendAndReceive()` operations. spring.rabbitmq.template.retry.enabled=false # Whether publishing retries are enabled.