Add Rabbit idleEventInterval property

This commit adds a property to configure how often idle container events
should be published.

See gh-6666
pull/7164/head
Maciej Walkowiak 8 years ago committed by Stephane Nicoll
parent ea3deae010
commit 47ec8630c8

@ -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;
}

@ -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()

@ -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);

Loading…
Cancel
Save