diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
index ca635c0250..397354c1b4 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -96,11 +96,18 @@ public class ConcurrentKafkaListenerContainerFactoryConfigurer {
PropertyMapper map = PropertyMapper.get();
Listener properties = this.properties.getListener();
map.from(properties::getAckMode).whenNonNull().to(container::setAckMode);
+ map.from(properties::getClientId).whenNonNull().to(container::setClientId);
map.from(properties::getAckCount).whenNonNull().to(container::setAckCount);
map.from(properties::getAckTime).whenNonNull().as(Duration::toMillis)
.to(container::setAckTime);
map.from(properties::getPollTimeout).whenNonNull().as(Duration::toMillis)
.to(container::setPollTimeout);
+ map.from(properties::getNoPollThreshold).whenNonNull().to(container::setNoPollThreshold);
+ map.from(properties::getIdleEventInterval).whenNonNull().as(Duration::toMillis)
+ .to(container::setIdleEventInterval);
+ map.from(properties::getMonitorInterval).whenNonNull().as(Duration::getSeconds)
+ .as(Number::intValue).to(container::setMonitorInterval);
+ map.from(properties::getLogContainerConfig).whenNonNull().to(container::setLogContainerConfig);
}
}
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java
index a64a9670f5..74524ba301 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.kafka;
import java.io.IOException;
import java.time.Duration;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -32,6 +33,7 @@ import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.bind.convert.DefaultDurationUnit;
import org.springframework.core.io.Resource;
import org.springframework.kafka.listener.AbstractMessageListenerContainer.AckMode;
import org.springframework.kafka.security.jaas.KafkaJaasLoginModuleInitializer;
@@ -797,6 +799,11 @@ public class KafkaProperties {
*/
private AckMode ackMode;
+ /**
+ * Prefix for the listener's consumer client.id property.
+ */
+ private String clientId;
+
/**
* Number of threads to run in the listener containers.
*/
@@ -807,6 +814,11 @@ public class KafkaProperties {
*/
private Duration pollTimeout;
+ /**
+ * Multiplier applied to "pollTimeout" to determine if a consumer is non-responsive.
+ */
+ private Float noPollThreshold;
+
/**
* Number of records between offset commits when ackMode is "COUNT" or
* "COUNT_TIME".
@@ -818,6 +830,23 @@ public class KafkaProperties {
*/
private Duration ackTime;
+ /**
+ * Time between publishing idle consumer events (no data received).
+ */
+ private Duration idleEventInterval;
+
+ /**
+ * Time between checks for non-responsive consumers. If a duration suffix is not
+ * specified, seconds will be used.
+ */
+ @DefaultDurationUnit(ChronoUnit.SECONDS)
+ private Duration monitorInterval;
+
+ /**
+ * Whether to log the container configuration during initialization (INFO level).
+ */
+ private Boolean logContainerConfig;
+
public Type getType() {
return this.type;
}
@@ -834,6 +863,14 @@ public class KafkaProperties {
this.ackMode = ackMode;
}
+ public String getClientId() {
+ return this.clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
public Integer getConcurrency() {
return this.concurrency;
}
@@ -850,6 +887,14 @@ public class KafkaProperties {
this.pollTimeout = pollTimeout;
}
+ public Float getNoPollThreshold() {
+ return this.noPollThreshold;
+ }
+
+ public void setNoPollThreshold(Float noPollThreshold) {
+ this.noPollThreshold = noPollThreshold;
+ }
+
public Integer getAckCount() {
return this.ackCount;
}
@@ -866,6 +911,30 @@ public class KafkaProperties {
this.ackTime = ackTime;
}
+ public Duration getIdleEventInterval() {
+ return this.idleEventInterval;
+ }
+
+ public void setIdleEventInterval(Duration idleEventInterval) {
+ this.idleEventInterval = idleEventInterval;
+ }
+
+ public Duration getMonitorInterval() {
+ return this.monitorInterval;
+ }
+
+ public void setMonitorInterval(Duration monitorInterval) {
+ this.monitorInterval = monitorInterval;
+ }
+
+ public Boolean getLogContainerConfig() {
+ return this.logContainerConfig;
+ }
+
+ public void setLogContainerConfig(Boolean logContainerConfig) {
+ this.logContainerConfig = logContainerConfig;
+ }
+
}
public static class Ssl {
diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
index 1fb5e66a84..802322c68e 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2017 the original author or authors.
+ * Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -254,11 +254,16 @@ public class KafkaAutoConfigurationTests {
this.contextRunner.withUserConfiguration(TestConfiguration.class)
.withPropertyValues("spring.kafka.template.default-topic=testTopic",
"spring.kafka.listener.ack-mode=MANUAL",
+ "spring.kafka.listener.client-id=client",
"spring.kafka.listener.ack-count=123",
"spring.kafka.listener.ack-time=456",
"spring.kafka.listener.concurrency=3",
"spring.kafka.listener.poll-timeout=2000",
+ "spring.kafka.listener.no-poll-threshold=2.5",
"spring.kafka.listener.type=batch",
+ "spring.kafka.listener.idle-event-interval=1s",
+ "spring.kafka.listener.monitor-interval=45",
+ "spring.kafka.listener.log-container-config=true",
"spring.kafka.jaas.enabled=true",
"spring.kafka.producer.transaction-id-prefix=foo",
"spring.kafka.jaas.login-module=foo",
@@ -285,6 +290,8 @@ public class KafkaAutoConfigurationTests {
.isEqualTo(consumerFactory);
assertThat(dfa.getPropertyValue("containerProperties.ackMode"))
.isEqualTo(AckMode.MANUAL);
+ assertThat(dfa.getPropertyValue("containerProperties.clientId"))
+ .isEqualTo("client");
assertThat(dfa.getPropertyValue("containerProperties.ackCount"))
.isEqualTo(123);
assertThat(dfa.getPropertyValue("containerProperties.ackTime"))
@@ -292,6 +299,14 @@ public class KafkaAutoConfigurationTests {
assertThat(dfa.getPropertyValue("concurrency")).isEqualTo(3);
assertThat(dfa.getPropertyValue("containerProperties.pollTimeout"))
.isEqualTo(2000L);
+ assertThat(dfa.getPropertyValue("containerProperties.noPollThreshold"))
+ .isEqualTo(2.5f);
+ assertThat(dfa.getPropertyValue("containerProperties.idleEventInterval"))
+ .isEqualTo(1000L);
+ assertThat(dfa.getPropertyValue("containerProperties.monitorInterval"))
+ .isEqualTo(45);
+ assertThat(dfa.getPropertyValue("containerProperties.logContainerConfig"))
+ .isEqualTo(Boolean.TRUE);
assertThat(dfa.getPropertyValue("batchListener")).isEqualTo(true);
assertThat(
context.getBeansOfType(KafkaJaasLoginModuleInitializer.class))
diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml
index 806c03ffe8..4d18ab5632 100644
--- a/spring-boot-project/spring-boot-dependencies/pom.xml
+++ b/spring-boot-project/spring-boot-dependencies/pom.xml
@@ -149,7 +149,7 @@
Kay-SR2
0.24.0.RELEASE
5.0.1.BUILD-SNAPSHOT
- 2.1.0.RELEASE
+ 2.1.1.BUILD-SNAPSHOT
2.3.2.RELEASE
1.2.0.RELEASE
2.0.0.RELEASE
diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
index d75d1d7b34..50a96ca792 100644
--- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
+++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
@@ -987,7 +987,12 @@ content into your application. Rather, pick only the properties that you need.
spring.kafka.listener.ack-count= # Number of records between offset commits when ackMode is "COUNT" or "COUNT_TIME".
spring.kafka.listener.ack-mode= # Listener AckMode. See the spring-kafka documentation.
spring.kafka.listener.ack-time= # Time between offset commits when ackMode is "TIME" or "COUNT_TIME".
+ spring.kafka.listener.client-id= # Prefix for the listener's consumer client.id property.
spring.kafka.listener.concurrency= # Number of threads to run in the listener containers.
+ spring.kafka.listener.idle-event-interval= # Time between publishing idle consumer events (no data received).
+ spring.kafka.listener.log-container-config= # Whether to log the container configuration during initialization (INFO level).
+ spring.kafka.listener.monitor-interval= # Time between checks for non-responsive consumers. If a duration suffix is not specified, seconds will be used.
+ spring.kafka.listener.no-poll-threshold= # Multiplier applied to "pollTimeout" to determine if a consumer is non-responsive.
spring.kafka.listener.poll-timeout= # Timeout to use when polling the consumer.
spring.kafka.listener.type=single # Listener type.
spring.kafka.producer.acks= # Number of acknowledgments the producer requires the leader to have received before considering a request complete.