Implement review remarks

This commit is contained in:
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 == 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 == Version 0.1.0

View File

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