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 6a8740b24d9..16d46758a75 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 @@ -146,11 +146,10 @@ public class RabbitAutoConfiguration { public RabbitTemplateConfigurer rabbitTemplateConfigurer(RabbitProperties properties, ObjectProvider messageConverter, ObjectProvider retryTemplateCustomizers) { - RabbitTemplateConfigurer configurer = new RabbitTemplateConfigurer(); + RabbitTemplateConfigurer configurer = new RabbitTemplateConfigurer(properties); configurer.setMessageConverter(messageConverter.getIfUnique()); configurer .setRetryTemplateCustomizers(retryTemplateCustomizers.orderedStream().collect(Collectors.toList())); - configurer.setRabbitProperties(properties); return configurer; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java index f7315d864b9..5c74a2d434d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitTemplateConfigurer.java @@ -23,6 +23,7 @@ import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.boot.context.properties.PropertyMapper; +import org.springframework.util.Assert; /** * Configure {@link RabbitTemplate} with sensible defaults. @@ -38,6 +39,26 @@ public class RabbitTemplateConfigurer { private RabbitProperties rabbitProperties; + /** + * Creates a new configurer. + * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * {@link #RabbitTemplateConfigurer(RabbitProperties)} + */ + @Deprecated + public RabbitTemplateConfigurer() { + + } + + /** + * Creates a new configurer that will use the given {@code rabbitProperties}. + * @param rabbitProperties properties to use + * @since 2.6.0 + */ + public RabbitTemplateConfigurer(RabbitProperties rabbitProperties) { + Assert.notNull(rabbitProperties, "RabbitProperties must not be null"); + this.rabbitProperties = rabbitProperties; + } + /** * Set the {@link MessageConverter} to use or {@code null} if the out-of-the-box * converter should be used. @@ -58,7 +79,10 @@ public class RabbitTemplateConfigurer { /** * Set the {@link RabbitProperties} to use. * @param rabbitProperties the {@link RabbitProperties} + * @deprecated since 2.6.0 for removal in 2.8.0 in favor of + * {@link #RabbitTemplateConfigurer(RabbitProperties)} */ + @Deprecated protected void setRabbitProperties(RabbitProperties rabbitProperties) { this.rabbitProperties = rabbitProperties; }