I have Kafka client with the following code,
private AdminClient getKafkaClient() {
final Map<String, Object> configs = new ConcurrentHashMap<>();
configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, "server-ip");
return AdminClient.create(configs);
}
This method invoked by multiple thread, and creates many admin client. So i wanted to keep in one instance and make use of it.
I've read an article for Singleton using Holder class with the below url,
Regarding static holder singleton pattern
Looks good to me, when i tried to implement issue setting config and can't create instance. Can any one suggest me best idea in my problem?
Thank you!