Refactor setting consumer group
This commit is contained in:
parent
bbb7829199
commit
225f1082f4
@ -1,6 +1,10 @@
|
|||||||
= KafkaHealthCheck
|
= KafkaHealthCheck
|
||||||
:icons: font
|
:icons: font
|
||||||
|
|
||||||
|
== Version 1.1.0
|
||||||
|
|
||||||
|
* Always set the kafka consumer group of this health check
|
||||||
|
|
||||||
== Version 0.1.0
|
== Version 0.1.0
|
||||||
|
|
||||||
* Develop kafka health check
|
* Develop kafka health check
|
||||||
|
@ -95,8 +95,10 @@ public class KafkaConsumingHealthIndicator extends AbstractHealthIndicator {
|
|||||||
|
|
||||||
private void setConsumerGroup(Map<String, Object> kafkaConsumerProperties) {
|
private void setConsumerGroup(Map<String, Object> kafkaConsumerProperties) {
|
||||||
try {
|
try {
|
||||||
kafkaConsumerProperties.putIfAbsent(ConsumerConfig.GROUP_ID_CONFIG,
|
String groupId = (String) kafkaConsumerProperties.getOrDefault(ConsumerConfig.GROUP_ID_CONFIG,
|
||||||
"health-check-" + InetAddress.getLocalHost().getHostAddress());
|
UUID.randomUUID().toString());
|
||||||
|
kafkaConsumerProperties.put(ConsumerConfig.GROUP_ID_CONFIG,
|
||||||
|
groupId + "-health-check-" + InetAddress.getLocalHost().getHostAddress());
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user