Skip to content

Commit 667a738

Browse files
garyrussellartembilan
authored andcommitted
Add isConsumerBatchEnabled() to listener container
In preparation for spring-projects/spring-integration#3172 Allow the inbound endpoint to detect if its listener container is configured to return batches.
1 parent 5e9ec03 commit 667a738

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,4 +47,14 @@ default void lazyLoad() {
4747
// no-op
4848
}
4949

50+
/**
51+
* Return true if this container is capable of (and configured to) create batches
52+
* of consumed messages.
53+
* @return true if enabled.
54+
* @since 2.2.4
55+
*/
56+
default boolean isConsumerBatchEnabled() {
57+
return false;
58+
}
59+
5060
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -378,6 +378,11 @@ public void setConsumerBatchEnabled(boolean consumerBatchEnabled) {
378378
this.consumerBatchEnabled = consumerBatchEnabled;
379379
}
380380

381+
@Override
382+
public boolean isConsumerBatchEnabled() {
383+
return this.consumerBatchEnabled;
384+
}
385+
381386
/**
382387
* {@inheritDoc}
383388
* <p>

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/listener/MessageListenerContainerRetryIntegrationTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -112,6 +112,7 @@ private void doTestRetryWithBatchListener(boolean stateful) throws Exception {
112112
});
113113
container.setAcknowledgeMode(AcknowledgeMode.AUTO);
114114
container.setConsumerBatchEnabled(true);
115+
assertThat(container.isConsumerBatchEnabled()).isTrue();
115116
container.setBatchSize(2);
116117

117118
final CountDownLatch latch = new CountDownLatch(1);

0 commit comments

Comments
 (0)