Browse Source

Deprecate spring.rabbitmq.template.queue

Closes gh-15301
pull/15310/head
Stephane Nicoll 7 years ago
parent
commit
8928cd1982
  1. 2
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java
  2. 18
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java
  3. 13
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
  4. 2
      spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

2
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java

@ -196,7 +196,7 @@ public class RabbitAutoConfiguration { @@ -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;
}

18
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java

@ -24,6 +24,7 @@ import java.util.List; @@ -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 { @@ -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 { @@ -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);
}
}

13
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java

@ -321,6 +321,19 @@ public class RabbitAutoConfigurationTests { @@ -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")

2
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. @@ -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.

Loading…
Cancel
Save