diff --git a/changelog.adoc b/changelog.adoc
index cb4dbfc..ee14ad1 100644
--- a/changelog.adoc
+++ b/changelog.adoc
@@ -1,10 +1,14 @@
= KafkaHealthCheck
:icons: font
-== Version 2.0.0
+== Version 1.3.0
-* Health check timeouts are configured in duration format.
-If you changed the defaults, please adapt your configuration.
+* Health check timeouts can now be configured in `java.time.Duration` format. The timeouts can still be configured using
+ millisecond values (`long`) as well to stay compatible with old configurations.
+
+== Version 1.2.0
+
+* Reduce logging level of health check calls to `TRACE`.
== Version 1.1.0
diff --git a/pom.xml b/pom.xml
index 3681495..d07e54c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.deviceinsight.kafka
kafka-health-check
- 2.0.0-SNAPSHOT
+ 1.3.0-SNAPSHOT
jar
Kafka Health Check
@@ -23,12 +23,13 @@
UTF-8
- 2.1.5.RELEASE
+ 2.1.10.RELEASE
2.2.4.RELEASE
2.7.0
3.1.6
5.4.2
3.11.1
+ 28.1-jre
3.0.1
2.22.2
@@ -87,6 +88,12 @@
${awaitility.version}
test
+
+ com.google.guava
+ guava
+ ${guava.version}
+ test
+
diff --git a/src/main/java/com/deviceinsight/kafka/health/KafkaHealthProperties.java b/src/main/java/com/deviceinsight/kafka/health/KafkaHealthProperties.java
index fd09e72..001dea8 100644
--- a/src/main/java/com/deviceinsight/kafka/health/KafkaHealthProperties.java
+++ b/src/main/java/com/deviceinsight/kafka/health/KafkaHealthProperties.java
@@ -25,6 +25,11 @@ public class KafkaHealthProperties {
this.sendReceiveTimeout = sendReceiveTimeout;
}
+ @Deprecated
+ public void setSendReceiveTimeoutMs(long sendReceiveTimeoutMs) {
+ setSendReceiveTimeout(Duration.ofMillis(sendReceiveTimeoutMs));
+ }
+
public Duration getPollTimeout() {
return pollTimeout;
}
@@ -33,6 +38,11 @@ public class KafkaHealthProperties {
this.pollTimeout = pollTimeout;
}
+ @Deprecated
+ public void setPollTimeoutMs(long pollTimeoutMs) {
+ setPollTimeout(Duration.ofMillis(pollTimeoutMs));
+ }
+
public Duration getSubscriptionTimeout() {
return subscriptionTimeout;
}
@@ -41,9 +51,14 @@ public class KafkaHealthProperties {
this.subscriptionTimeout = subscriptionTimeout;
}
+ @Deprecated
+ public void setSubscriptionTimeoutMs(long subscriptionTimeoutMs) {
+ setSubscriptionTimeout(Duration.ofMillis(subscriptionTimeoutMs));
+ }
+
@Override
public String toString() {
- return "KafkaHealthProperties{" + "topic='" + topic + '\'' + ", sendReceiveTimeout=" + sendReceiveTimeout +
+ return "KafkaHealthProperties{topic='" + topic + "', sendReceiveTimeout=" + sendReceiveTimeout +
", pollTimeout=" + pollTimeout + ", subscriptionTimeout=" + subscriptionTimeout + '}';
}
}
diff --git a/src/test/java/com/deviceinsight/kafka/health/KafkaHealthPropertiesTest.java b/src/test/java/com/deviceinsight/kafka/health/KafkaHealthPropertiesTest.java
new file mode 100644
index 0000000..e2add27
--- /dev/null
+++ b/src/test/java/com/deviceinsight/kafka/health/KafkaHealthPropertiesTest.java
@@ -0,0 +1,54 @@
+package com.deviceinsight.kafka.health;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.params.provider.Arguments.arguments;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
+import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
+
+import java.time.Duration;
+import java.util.stream.Stream;
+
+public class KafkaHealthPropertiesTest {
+
+ // @formatter:off
+ private static final ConfigurationPropertySource DURATION_PROPERTY_SOURCE = new MapConfigurationPropertySource(ImmutableMap.of(
+ "kafka.health.topic", "custom-topic",
+ "kafka.health.send-receive-timeout", "1m",
+ "kafka.health.poll-timeout", "2s",
+ "kafka.health.subscription-timeout", "10s"
+ ));
+
+ private static final ConfigurationPropertySource MILLISECONDS_PROPERTY_SOURCE = new MapConfigurationPropertySource(ImmutableMap.of(
+ "kafka.health.topic", "custom-topic",
+ "kafka.health.send-receive-timeout-ms", "60000",
+ "kafka.health.poll-timeout-ms", "2000",
+ "kafka.health.subscription-timeout-ms", "10000"
+ ));
+ // @formatter:on
+
+ @ParameterizedTest(name = "using {0} based setters")
+ @MethodSource("configurationPropertySources")
+ public void test_that_properties_bind_to_KafkaHealthProperties(String sourceName,
+ ConfigurationPropertySource propertySource) {
+
+ KafkaHealthProperties kafkaHealthProperties =
+ new Binder(propertySource).bind("kafka.health", KafkaHealthProperties.class).get();
+
+ assertThat(kafkaHealthProperties.getTopic()).isEqualTo("custom-topic");
+ assertThat(kafkaHealthProperties.getSendReceiveTimeout()).isEqualTo(Duration.ofMinutes(1));
+ assertThat(kafkaHealthProperties.getPollTimeout()).isEqualTo(Duration.ofSeconds(2));
+ assertThat(kafkaHealthProperties.getSubscriptionTimeout()).isEqualTo(Duration.ofSeconds(10));
+ }
+
+ static Stream configurationPropertySources() {
+ return Stream.of(arguments("Duration", DURATION_PROPERTY_SOURCE),
+ arguments("long (milliseconds)", MILLISECONDS_PROPERTY_SOURCE));
+ }
+
+}