diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 44750b1c44..b20d1075c7 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -503,6 +503,11 @@ public class RabbitProperties { */ private Boolean defaultRequeueRejected; + /** + * How often to publish idle container events. + */ + private Long idleEventInterval; + /** * Optional properties for a retry interceptor. */ @@ -565,6 +570,14 @@ public class RabbitProperties { this.defaultRequeueRejected = defaultRequeueRejected; } + public Long getIdleEventInterval() { + return idleEventInterval; + } + + public void setIdleEventInterval(Long idleEventInterval) { + this.idleEventInterval = idleEventInterval; + } + public ListenerRetry getRetry() { return this.retry; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java index 037e86601b..a54835a50b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java @@ -90,6 +90,9 @@ public final class SimpleRabbitListenerContainerFactoryConfigurer { if (listenerConfig.getDefaultRequeueRejected() != null) { factory.setDefaultRequeueRejected(listenerConfig.getDefaultRequeueRejected()); } + if (listenerConfig.getIdleEventInterval() != null) { + factory.setIdleEventInterval(listenerConfig.getIdleEventInterval()); + } ListenerRetry retryConfig = listenerConfig.getRetry(); if (retryConfig.isEnabled()) { RetryInterceptorBuilder builder = (retryConfig.isStateless() diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index a0c54db8fd..bc9c877fbe 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -303,6 +303,7 @@ public class RabbitAutoConfigurationTests { "spring.rabbitmq.listener.maxConcurrency:10", "spring.rabbitmq.listener.prefetch:40", "spring.rabbitmq.listener.defaultRequeueRejected:false", + "spring.rabbitmq.listener.idleEventInterval:5", "spring.rabbitmq.listener.transactionSize:20"); SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context .getBean("rabbitListenerContainerFactory", @@ -319,6 +320,7 @@ public class RabbitAutoConfigurationTests { .isSameAs(this.context.getBean("myMessageConverter")); assertThat(dfa.getPropertyValue("defaultRequeueRejected")) .isEqualTo(Boolean.FALSE); + assertThat(dfa.getPropertyValue("idleEventInterval")).isEqualTo(5L); Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain"); assertThat(adviceChain).isNotNull(); assertThat(adviceChain.length).isEqualTo(1);