Skip to content

Commit a0d4651

Browse files
committed
Merge pull request #28290 from pascal-ayotte
* pr/28290: Polish "Add support for IdlePartitionEventInterval" Add support for IdlePartitionEventInterval Closes gh-28290
2 parents 3d5ea71 + 91d7295 commit a0d4651

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -199,6 +199,8 @@ private void configureContainer(ContainerProperties container) {
199199
map.from(properties::getNoPollThreshold).to(container::setNoPollThreshold);
200200
map.from(properties.getIdleBetweenPolls()).as(Duration::toMillis).to(container::setIdleBetweenPolls);
201201
map.from(properties::getIdleEventInterval).as(Duration::toMillis).to(container::setIdleEventInterval);
202+
map.from(properties::getIdlePartitionEventInterval).as(Duration::toMillis)
203+
.to(container::setIdlePartitionEventInterval);
202204
map.from(properties::getMonitorInterval).as(Duration::getSeconds).as(Number::intValue)
203205
.to(container::setMonitorInterval);
204206
map.from(properties::getLogContainerConfig).to(container::setLogContainerConfig);

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -902,6 +902,12 @@ public enum Type {
902902
*/
903903
private Duration idleEventInterval;
904904

905+
/**
906+
* Time between publishing idle partition consumer events (no data received for
907+
* partition).
908+
*/
909+
private Duration idlePartitionEventInterval;
910+
905911
/**
906912
* Time between checks for non-responsive consumers. If a duration suffix is not
907913
* specified, seconds will be used.
@@ -1006,6 +1012,14 @@ public void setIdleEventInterval(Duration idleEventInterval) {
10061012
this.idleEventInterval = idleEventInterval;
10071013
}
10081014

1015+
public Duration getIdlePartitionEventInterval() {
1016+
return this.idlePartitionEventInterval;
1017+
}
1018+
1019+
public void setIdlePartitionEventInterval(Duration idlePartitionEventInterval) {
1020+
this.idlePartitionEventInterval = idlePartitionEventInterval;
1021+
}
1022+
10091023
public Duration getMonitorInterval() {
10101024
return this.monitorInterval;
10111025
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -389,6 +389,7 @@ void listenerProperties() {
389389
"spring.kafka.listener.concurrency=3", "spring.kafka.listener.poll-timeout=2000",
390390
"spring.kafka.listener.no-poll-threshold=2.5", "spring.kafka.listener.type=batch",
391391
"spring.kafka.listener.idle-between-polls=1s", "spring.kafka.listener.idle-event-interval=1s",
392+
"spring.kafka.listener.idle-partition-event-interval=1s",
392393
"spring.kafka.listener.monitor-interval=45", "spring.kafka.listener.log-container-config=true",
393394
"spring.kafka.listener.only-log-record-metadata=true",
394395
"spring.kafka.listener.missing-topics-fatal=true", "spring.kafka.jaas.enabled=true",
@@ -415,6 +416,7 @@ void listenerProperties() {
415416
assertThat(containerProperties.getNoPollThreshold()).isEqualTo(2.5f);
416417
assertThat(containerProperties.getIdleBetweenPolls()).isEqualTo(1000L);
417418
assertThat(containerProperties.getIdleEventInterval()).isEqualTo(1000L);
419+
assertThat(containerProperties.getIdlePartitionEventInterval()).isEqualTo(1000L);
418420
assertThat(containerProperties.getMonitorInterval()).isEqualTo(45);
419421
assertThat(containerProperties.isLogContainerConfig()).isTrue();
420422
assertThat(containerProperties.isOnlyLogRecordMetadata()).isTrue();

0 commit comments

Comments
 (0)