Browse Source

Merge pull request #6666 from maciejwalkowiak:spring-amqp-idle-event-interval-property

* pr/6666:
  Polish contribution
  Add Rabbit idleEventInterval property
pull/7164/head
Stephane Nicoll 9 years ago
parent
commit
5976d44f6c
  1. 13
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java
  2. 3
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java
  3. 2
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java
  4. 1
      spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

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

@ -503,6 +503,11 @@ public class RabbitProperties { @@ -503,6 +503,11 @@ public class RabbitProperties {
*/
private Boolean defaultRequeueRejected;
/**
* How often idle container events should be published in milliseconds.
*/
private Long idleEventInterval;
/**
* Optional properties for a retry interceptor.
*/
@ -565,6 +570,14 @@ public class RabbitProperties { @@ -565,6 +570,14 @@ public class RabbitProperties {
this.defaultRequeueRejected = defaultRequeueRejected;
}
public Long getIdleEventInterval() {
return this.idleEventInterval;
}
public void setIdleEventInterval(Long idleEventInterval) {
this.idleEventInterval = idleEventInterval;
}
public ListenerRetry getRetry() {
return this.retry;
}

3
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java

@ -90,6 +90,9 @@ public final class SimpleRabbitListenerContainerFactoryConfigurer { @@ -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()

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

@ -303,6 +303,7 @@ public class RabbitAutoConfigurationTests { @@ -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 { @@ -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);

1
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

@ -863,6 +863,7 @@ content into your application; rather pick only the properties that you need. @@ -863,6 +863,7 @@ content into your application; rather pick only the properties that you need.
spring.rabbitmq.listener.auto-startup=true # Start the container automatically on startup.
spring.rabbitmq.listener.concurrency= # Minimum number of consumers.
spring.rabbitmq.listener.default-requeue-rejected= # Whether or not to requeue delivery failures; default `true`.
spring.rabbitmq.idle-event-interval= # How often idle container events should be published in milliseconds.
spring.rabbitmq.listener.max-concurrency= # Maximum number of consumers.
spring.rabbitmq.listener.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
spring.rabbitmq.listener.retry.enabled=false # Whether or not publishing retries are enabled.

Loading…
Cancel
Save