Skip to content

Commit 14dee1f

Browse files
committed
Consumer Batching Polishing
Change boolean assertion; simply enforce the condition.
1 parent 6ed9925 commit 14dee1f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ public void setBatchSize(int batchSize) {
357357

358358
/**
359359
* Set to true to present a list of messages based on the {@link #setBatchSize(int)},
360-
* if the listener supports it.
360+
* if the listener supports it. This will coerce {@link #setDeBatchingEnabled(boolean)
361+
* deBatchingEnabled} to true as well.
361362
* @param consumerBatchEnabled true to create message batches in the container.
362363
* @since 2.2
363364
* @see #setBatchSize(int)
@@ -512,8 +513,9 @@ protected final boolean sharedConnectionEnabled() {
512513

513514
@Override
514515
protected void doInitialize() {
515-
Assert.state(!this.consumerBatchEnabled || isDeBatchingEnabled(),
516-
"When setting 'consumerBatchEnabled' to true, 'deBatchingEnabled' must also be true");
516+
if (this.consumerBatchEnabled) {
517+
setDeBatchingEnabled(true);
518+
}
517519
}
518520

519521
@ManagedMetric(metricType = MetricType.GAUGE)

0 commit comments

Comments
 (0)