kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject Re: Kafka as K/V store
Date Wed, 09 May 2018 16:59:18 GMT
   //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 <sbpothineni@gmail.com>
Sent: Wednesday, May 9, 2018 10:46 AM
To: users@kafka.apache.org
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message