Skip to content

Add support for configuring missingQueuesFatal property #14252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public void configure(DirectRabbitListenerContainerFactory factory,
configure(factory, connectionFactory, config);
map.from(config::getConsumersPerQueue).whenNonNull()
.to(factory::setConsumersPerQueue);
map.from(config::getMissingQueuesFatal).whenNonNull()
.to(factory::setMissingQueuesFatal);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,13 @@ public static class SimpleContainer extends AmqpContainer {
*/
private Integer transactionSize;

/**
* 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.
*/
private Boolean missingQueuesFatal;

public Integer getConcurrency() {
return this.concurrency;
}
Expand All @@ -663,6 +670,14 @@ public void setTransactionSize(Integer transactionSize) {
this.transactionSize = transactionSize;
}

public Boolean getMissingQueuesFatal() {
return this.missingQueuesFatal;
}

public void setMissingQueuesFatal(Boolean missingQueuesFatal) {
this.missingQueuesFatal = missingQueuesFatal;
}

}

/**
Expand All @@ -675,6 +690,12 @@ public static class DirectContainer extends AmqpContainer {
*/
private Integer consumersPerQueue;

/**
* Whether the context should be ended up with failure if there are no any queues
* available on the broker.
*/
private Boolean missingQueuesFatal;

public Integer getConsumersPerQueue() {
return this.consumersPerQueue;
}
Expand All @@ -683,6 +704,14 @@ public void setConsumersPerQueue(Integer consumersPerQueue) {
this.consumersPerQueue = consumersPerQueue;
}

public Boolean getMissingQueuesFatal() {
return this.missingQueuesFatal;
}

public void setMissingQueuesFatal(Boolean missingQueuesFatal) {
this.missingQueuesFatal = missingQueuesFatal;
}

}

public static class Template {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public void configure(SimpleRabbitListenerContainerFactory factory,
map.from(config::getMaxConcurrency).whenNonNull()
.to(factory::setMaxConcurrentConsumers);
map.from(config::getTransactionSize).whenNonNull().to(factory::setTxSize);
map.from(config::getMissingQueuesFatal).whenNonNull()
.to(factory::setMissingQueuesFatal);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ public void testSimpleRabbitListenerContainerFactoryWithCustomSettings() {
"spring.rabbitmq.listener.simple.maxConcurrency:10",
"spring.rabbitmq.listener.simple.prefetch:40",
"spring.rabbitmq.listener.simple.defaultRequeueRejected:false",
"spring.rabbitmq.listener.simple.missingQueuesFatal:false",
"spring.rabbitmq.listener.simple.idleEventInterval:5",
"spring.rabbitmq.listener.simple.transactionSize:20")
.run((context) -> {
Expand Down Expand Up @@ -496,6 +497,7 @@ public void testDirectRabbitListenerContainerFactoryWithCustomSettings() {
"spring.rabbitmq.listener.direct.consumers-per-queue:5",
"spring.rabbitmq.listener.direct.prefetch:40",
"spring.rabbitmq.listener.direct.defaultRequeueRejected:false",
"spring.rabbitmq.listener.direct.missingQueuesFatal:false",
"spring.rabbitmq.listener.direct.idleEventInterval:5")
.run((context) -> {
DirectRabbitListenerContainerFactory rabbitListenerContainerFactory = context
Expand Down Expand Up @@ -617,6 +619,7 @@ private void checkCommonProps(AssertableApplicationContext context,
assertThat(dfa.getPropertyValue("prefetchCount")).isEqualTo(40);
assertThat(dfa.getPropertyValue("messageConverter"))
.isSameAs(context.getBean("myMessageConverter"));
assertThat(dfa.getPropertyValue("missingQueuesFatal")).isEqualTo(false);
assertThat(dfa.getPropertyValue("defaultRequeueRejected"))
.isEqualTo(Boolean.FALSE);
assertThat(dfa.getPropertyValue("idleEventInterval")).isEqualTo(5L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ content into your application. Rather, pick only the properties that you need.
spring.rabbitmq.listener.direct.consumers-per-queue= # Number of consumers per queue.
spring.rabbitmq.listener.direct.default-requeue-rejected= # Whether rejected deliveries are re-queued by default.
spring.rabbitmq.listener.direct.idle-event-interval= # How often idle container events should be published.
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.
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).
spring.rabbitmq.listener.direct.retry.enabled=false # Whether publishing retries are enabled.
spring.rabbitmq.listener.direct.retry.initial-interval=1000ms # Duration between the first and second attempt to deliver a message.
Expand All @@ -1151,6 +1152,7 @@ content into your application. Rather, pick only the properties that you need.
spring.rabbitmq.listener.simple.default-requeue-rejected= # Whether rejected deliveries are re-queued by default.
spring.rabbitmq.listener.simple.idle-event-interval= # How often idle container events should be published.
spring.rabbitmq.listener.simple.max-concurrency= # Maximum number of listener invoker threads.
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.
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).
spring.rabbitmq.listener.simple.retry.enabled=false # Whether publishing retries are enabled.
spring.rabbitmq.listener.simple.retry.initial-interval=1000ms # Duration between the first and second attempt to deliver a message.
Expand Down