Skip to content

Commit e9ab269

Browse files
committed
Polish "Add a configuration property for KLC's idleBetweenPolls"
See gh-23048
1 parent 03a8937 commit e9ab269

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ 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);
190-
map.from(properties.getIdleBetweenPolls()).as(Duration::toMillis).to(container::setIdleBetweenPolls);
191191
map.from(properties::getLogContainerConfig).to(container::setLogContainerConfig);
192192
map.from(properties::isMissingTopicsFatal).to(container::setMissingTopicsFatal);
193193
map.from(this.transactionManager).to(container::setTransactionManager);

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -886,15 +886,14 @@ public enum Type {
886886
private Duration ackTime;
887887

888888
/**
889-
* Time between publishing idle consumer events (no data received).
889+
* Sleep interval between Consumer.poll(Duration) calls.
890890
*/
891-
private Duration idleEventInterval;
891+
private Duration idleBetweenPolls = Duration.ZERO;
892892

893893
/**
894-
* The sleep interval in milliseconds between
895-
* {@link org.apache.kafka.clients.consumer.Consumer#poll(Duration)} calls.
894+
* Time between publishing idle consumer events (no data received).
896895
*/
897-
private Duration idleBetweenPolls;
896+
private Duration idleEventInterval;
898897

899898
/**
900899
* Time between checks for non-responsive consumers. If a duration suffix is not
@@ -978,20 +977,20 @@ public void setAckTime(Duration ackTime) {
978977
this.ackTime = ackTime;
979978
}
980979

981-
public Duration getIdleEventInterval() {
982-
return this.idleEventInterval;
980+
public Duration getIdleBetweenPolls() {
981+
return this.idleBetweenPolls;
983982
}
984983

985-
public void setIdleEventInterval(Duration idleEventInterval) {
986-
this.idleEventInterval = idleEventInterval;
984+
public void setIdleBetweenPolls(Duration idleBetweenPolls) {
985+
this.idleBetweenPolls = idleBetweenPolls;
987986
}
988987

989-
public Duration getIdleBetweenPolls() {
990-
return idleBetweenPolls;
988+
public Duration getIdleEventInterval() {
989+
return this.idleEventInterval;
991990
}
992991

993-
public void setIdleBetweenPolls(Duration idleBetweenPolls) {
994-
this.idleBetweenPolls = idleBetweenPolls;
992+
public void setIdleEventInterval(Duration idleEventInterval) {
993+
this.idleEventInterval = idleEventInterval;
995994
}
996995

997996
public Duration getMonitorInterval() {
@@ -1017,6 +1016,7 @@ public boolean isMissingTopicsFatal() {
10171016
public void setMissingTopicsFatal(boolean missingTopicsFatal) {
10181017
this.missingTopicsFatal = missingTopicsFatal;
10191018
}
1019+
10201020
}
10211021

10221022
public static class Ssl {

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)