Implement review remarks

feature/refactor-health-strategy
Emanuel Zienecker 2019-05-24 13:02:45 +02:00
parent 225f1082f4
commit 4ab7e57580
2 changed files with 3 additions and 2 deletions

View File

@ -3,7 +3,7 @@
== Version 1.1.0
* Always set the kafka consumer group of this health check
* Make consumer groups unique by appending a random UUID when no group ID is configured explicitly.
== Version 0.1.0

View File

@ -42,6 +42,7 @@ import javax.annotation.PreDestroy;
public class KafkaConsumingHealthIndicator extends AbstractHealthIndicator {
private static final Logger logger = LoggerFactory.getLogger(KafkaConsumingHealthIndicator.class);
private static final String CONSUMER_GROUP_PREFIX = "health-check-";
private final Consumer<String, String> consumer;
@ -98,7 +99,7 @@ public class KafkaConsumingHealthIndicator extends AbstractHealthIndicator {
String groupId = (String) kafkaConsumerProperties.getOrDefault(ConsumerConfig.GROUP_ID_CONFIG,
UUID.randomUUID().toString());
kafkaConsumerProperties.put(ConsumerConfig.GROUP_ID_CONFIG,
groupId + "-health-check-" + InetAddress.getLocalHost().getHostAddress());
CONSUMER_GROUP_PREFIX + groupId + "-" + InetAddress.getLocalHost().getHostAddress());
} catch (UnknownHostException e) {
throw new IllegalStateException(e);
}