//best to do your generic type declaration <K extends String> at class level
and refer to <K> later
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
//best to do generic type declaration <V extends String> at class level and
refer to <V> later
java.util.HashMap<K extends String,V extends String> hashMap=new
java.util.HashMap<K extends String,V extends String>();
hashMap.put("topic1","topic1");
hashMap.put("topic2","topic2");
//any put or remove from hashMap would happen here
//be careful as subscribe will replace existing topics with hashMap.values()
consumer.subscribe((java.util.Collection<String>)hashMap.values());
you can try above statement
Martin
______________________________________________
________________________________
From: Sudhir Babu Pothineni <[email protected]>
Sent: Wednesday, May 9, 2018 10:46 AM
To: [email protected]
Subject: Kafka as K/V store
We would like to use Kafka as a key/value store. We need put, get and subscribe
a particular “key”.
Any pointers how to do this?
Thanks
Sudhir