Skip to content

Commit c1322a5

Browse files
committed
Polish "Add support for configuring missingQueuesFatal property"
Closes gh-14252
1 parent 91e731a commit c1322a5

File tree

6 files changed

+23
-39
lines changed

6 files changed

+23
-39
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ protected void configure(T factory, ConnectionFactory connectionFactory,
116116
if (configuration.getIdleEventInterval() != null) {
117117
factory.setIdleEventInterval(configuration.getIdleEventInterval().toMillis());
118118
}
119+
if (configuration.getMissingQueuesFatal() != null) {
120+
factory.setMissingQueuesFatal(configuration.getMissingQueuesFatal());
121+
}
119122
ListenerRetry retryConfig = configuration.getRetry();
120123
if (retryConfig.isEnabled()) {
121124
RetryInterceptorBuilder<?> builder = (retryConfig.isStateless())

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public void configure(DirectRabbitListenerContainerFactory factory,
4040
configure(factory, connectionFactory, config);
4141
map.from(config::getConsumersPerQueue).whenNonNull()
4242
.to(factory::setConsumersPerQueue);
43-
map.from(config::getMissingQueuesFatal).whenNonNull()
44-
.to(factory::setMissingQueuesFatal);
4543
}
4644

4745
}

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

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ public abstract static class AmqpContainer {
592592
*/
593593
private Duration idleEventInterval;
594594

595+
/**
596+
* Whether to fail if the queues declared by the container are not available on
597+
* the broker.
598+
*/
599+
private Boolean missingQueuesFatal;
600+
595601
/**
596602
* Optional properties for a retry interceptor.
597603
*/
@@ -637,6 +643,14 @@ public void setIdleEventInterval(Duration idleEventInterval) {
637643
this.idleEventInterval = idleEventInterval;
638644
}
639645

646+
public Boolean getMissingQueuesFatal() {
647+
return this.missingQueuesFatal;
648+
}
649+
650+
public void setMissingQueuesFatal(Boolean missingQueuesFatal) {
651+
this.missingQueuesFatal = missingQueuesFatal;
652+
}
653+
640654
public ListenerRetry getRetry() {
641655
return this.retry;
642656
}
@@ -665,13 +679,6 @@ public static class SimpleContainer extends AmqpContainer {
665679
*/
666680
private Integer transactionSize;
667681

668-
/**
669-
* Whether the context should be ended up with failure if there are no any queues
670-
* available on the broker or the container should be stopped if queues have been
671-
* removed while the container is running.
672-
*/
673-
private Boolean missingQueuesFatal;
674-
675682
public Integer getConcurrency() {
676683
return this.concurrency;
677684
}
@@ -696,14 +703,6 @@ public void setTransactionSize(Integer transactionSize) {
696703
this.transactionSize = transactionSize;
697704
}
698705

699-
public Boolean getMissingQueuesFatal() {
700-
return this.missingQueuesFatal;
701-
}
702-
703-
public void setMissingQueuesFatal(Boolean missingQueuesFatal) {
704-
this.missingQueuesFatal = missingQueuesFatal;
705-
}
706-
707706
}
708707

709708
/**
@@ -716,12 +715,6 @@ public static class DirectContainer extends AmqpContainer {
716715
*/
717716
private Integer consumersPerQueue;
718717

719-
/**
720-
* Whether the context should be ended up with failure if there are no any queues
721-
* available on the broker.
722-
*/
723-
private Boolean missingQueuesFatal;
724-
725718
public Integer getConsumersPerQueue() {
726719
return this.consumersPerQueue;
727720
}
@@ -730,14 +723,6 @@ public void setConsumersPerQueue(Integer consumersPerQueue) {
730723
this.consumersPerQueue = consumersPerQueue;
731724
}
732725

733-
public Boolean getMissingQueuesFatal() {
734-
return this.missingQueuesFatal;
735-
}
736-
737-
public void setMissingQueuesFatal(Boolean missingQueuesFatal) {
738-
this.missingQueuesFatal = missingQueuesFatal;
739-
}
740-
741726
}
742727

743728
public static class Template {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ public void configure(SimpleRabbitListenerContainerFactory factory,
4343
map.from(config::getMaxConcurrency).whenNonNull()
4444
.to(factory::setMaxConcurrentConsumers);
4545
map.from(config::getTransactionSize).whenNonNull().to(factory::setTxSize);
46-
map.from(config::getMissingQueuesFatal).whenNonNull()
47-
.to(factory::setMissingQueuesFatal);
4846
}
4947

5048
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ public void testSimpleRabbitListenerContainerFactoryWithCustomSettings() {
468468
"spring.rabbitmq.listener.simple.maxConcurrency:10",
469469
"spring.rabbitmq.listener.simple.prefetch:40",
470470
"spring.rabbitmq.listener.simple.defaultRequeueRejected:false",
471-
"spring.rabbitmq.listener.simple.missingQueuesFatal:false",
472471
"spring.rabbitmq.listener.simple.idleEventInterval:5",
472+
"spring.rabbitmq.listener.simple.missingQueuesFatal:false",
473473
"spring.rabbitmq.listener.simple.transactionSize:20")
474474
.run((context) -> {
475475
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = context
@@ -501,8 +501,8 @@ public void testDirectRabbitListenerContainerFactoryWithCustomSettings() {
501501
"spring.rabbitmq.listener.direct.consumers-per-queue:5",
502502
"spring.rabbitmq.listener.direct.prefetch:40",
503503
"spring.rabbitmq.listener.direct.defaultRequeueRejected:false",
504-
"spring.rabbitmq.listener.direct.missingQueuesFatal:false",
505-
"spring.rabbitmq.listener.direct.idleEventInterval:5")
504+
"spring.rabbitmq.listener.direct.idleEventInterval:5",
505+
"spring.rabbitmq.listener.direct.missingQueuesFatal:false")
506506
.run((context) -> {
507507
DirectRabbitListenerContainerFactory rabbitListenerContainerFactory = context
508508
.getBean("rabbitListenerContainerFactory",
@@ -623,10 +623,10 @@ private void checkCommonProps(AssertableApplicationContext context,
623623
assertThat(dfa.getPropertyValue("prefetchCount")).isEqualTo(40);
624624
assertThat(dfa.getPropertyValue("messageConverter"))
625625
.isSameAs(context.getBean("myMessageConverter"));
626-
assertThat(dfa.getPropertyValue("missingQueuesFatal")).isEqualTo(false);
627626
assertThat(dfa.getPropertyValue("defaultRequeueRejected"))
628627
.isEqualTo(Boolean.FALSE);
629628
assertThat(dfa.getPropertyValue("idleEventInterval")).isEqualTo(5L);
629+
assertThat(dfa.getPropertyValue("missingQueuesFatal")).isEqualTo(false);
630630
Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
631631
assertThat(adviceChain).isNotNull();
632632
assertThat(adviceChain.length).isEqualTo(1);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ content into your application. Rather, pick only the properties that you need.
11371137
spring.rabbitmq.listener.direct.consumers-per-queue= # Number of consumers per queue.
11381138
spring.rabbitmq.listener.direct.default-requeue-rejected= # Whether rejected deliveries are re-queued by default.
11391139
spring.rabbitmq.listener.direct.idle-event-interval= # How often idle container events should be published.
1140-
spring.rabbitmq.listener.direct.missing-queues-fatal= # Whether the context should be ended up with failure if there are no any queues available on the broker.
1140+
spring.rabbitmq.listener.direct.missing-queues-fatal= # Whether to fail if the queues declared by the container are not available on the broker.
11411141
spring.rabbitmq.listener.direct.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
11421142
spring.rabbitmq.listener.direct.retry.enabled=false # Whether publishing retries are enabled.
11431143
spring.rabbitmq.listener.direct.retry.initial-interval=1000ms # Duration between the first and second attempt to deliver a message.
@@ -1151,7 +1151,7 @@ content into your application. Rather, pick only the properties that you need.
11511151
spring.rabbitmq.listener.simple.default-requeue-rejected= # Whether rejected deliveries are re-queued by default.
11521152
spring.rabbitmq.listener.simple.idle-event-interval= # How often idle container events should be published.
11531153
spring.rabbitmq.listener.simple.max-concurrency= # Maximum number of listener invoker threads.
1154-
spring.rabbitmq.listener.simple.missing-queues-fatal= # Whether the context should be ended up with failure if there are no any queues available on the broker or the container should be stopped if queues have been removed while the container is running.
1154+
spring.rabbitmq.listener.simple.missing-queues-fatal= # Whether to fail if the queues declared by the container are not available on the broker.
11551155
spring.rabbitmq.listener.simple.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used).
11561156
spring.rabbitmq.listener.simple.retry.enabled=false # Whether publishing retries are enabled.
11571157
spring.rabbitmq.listener.simple.retry.initial-interval=1000ms # Duration between the first and second attempt to deliver a message.

0 commit comments

Comments
 (0)