Skip to content

Commit 1b8bfaa

Browse files
committed
Merge pull request #23048 from s50600822
* gh-23048: Polish "Add a configuration property for KLC's idleBetweenPolls" Add a configuration property for KLC's idleBetweenPolls Closes gh-23048
2 parents 56ded38 + e9ab269 commit 1b8bfaa

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private void configureContainer(ContainerProperties container) {
184184
map.from(properties::getAckTime).as(Duration::toMillis).to(container::setAckTime);
185185
map.from(properties::getPollTimeout).as(Duration::toMillis).to(container::setPollTimeout);
186186
map.from(properties::getNoPollThreshold).to(container::setNoPollThreshold);
187+
map.from(properties.getIdleBetweenPolls()).as(Duration::toMillis).to(container::setIdleBetweenPolls);
187188
map.from(properties::getIdleEventInterval).as(Duration::toMillis).to(container::setIdleEventInterval);
188189
map.from(properties::getMonitorInterval).as(Duration::getSeconds).as(Number::intValue)
189190
.to(container::setMonitorInterval);

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,11 @@ public enum Type {
885885
*/
886886
private Duration ackTime;
887887

888+
/**
889+
* Sleep interval between Consumer.poll(Duration) calls.
890+
*/
891+
private Duration idleBetweenPolls = Duration.ZERO;
892+
888893
/**
889894
* Time between publishing idle consumer events (no data received).
890895
*/
@@ -972,6 +977,14 @@ public void setAckTime(Duration ackTime) {
972977
this.ackTime = ackTime;
973978
}
974979

980+
public Duration getIdleBetweenPolls() {
981+
return this.idleBetweenPolls;
982+
}
983+
984+
public void setIdleBetweenPolls(Duration idleBetweenPolls) {
985+
this.idleBetweenPolls = idleBetweenPolls;
986+
}
987+
975988
public Duration getIdleEventInterval() {
976989
return this.idleEventInterval;
977990
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ void listenerProperties() {
368368
"spring.kafka.listener.ack-count=123", "spring.kafka.listener.ack-time=456",
369369
"spring.kafka.listener.concurrency=3", "spring.kafka.listener.poll-timeout=2000",
370370
"spring.kafka.listener.no-poll-threshold=2.5", "spring.kafka.listener.type=batch",
371-
"spring.kafka.listener.idle-event-interval=1s", "spring.kafka.listener.monitor-interval=45",
372-
"spring.kafka.listener.log-container-config=true",
371+
"spring.kafka.listener.idle-between-polls=1s", "spring.kafka.listener.idle-event-interval=1s",
372+
"spring.kafka.listener.monitor-interval=45", "spring.kafka.listener.log-container-config=true",
373373
"spring.kafka.listener.missing-topics-fatal=true", "spring.kafka.jaas.enabled=true",
374374
"spring.kafka.producer.transaction-id-prefix=foo", "spring.kafka.jaas.login-module=foo",
375375
"spring.kafka.jaas.control-flag=REQUISITE", "spring.kafka.jaas.options.useKeyTab=true")
@@ -392,6 +392,7 @@ void listenerProperties() {
392392
assertThat(containerProperties.getAckTime()).isEqualTo(456L);
393393
assertThat(containerProperties.getPollTimeout()).isEqualTo(2000L);
394394
assertThat(containerProperties.getNoPollThreshold()).isEqualTo(2.5f);
395+
assertThat(containerProperties.getIdleBetweenPolls()).isEqualTo(1000L);
395396
assertThat(containerProperties.getIdleEventInterval()).isEqualTo(1000L);
396397
assertThat(containerProperties.getMonitorInterval()).isEqualTo(45);
397398
assertThat(containerProperties.isLogContainerConfig()).isTrue();

0 commit comments

Comments
 (0)