On small addition: If your input topic does not have any key specified, you can still extract a key from the value
KTable source = builder.stream(...).selectKey(...).toTable(...) -Matthias On 06/15/2016 08:30 PM, Eno Thereska wrote: > Hi Adrienne, > > How do you enter the input on t1 topic? If using kafka-console-producer, > you'll need to pass in keys as well as values. Here is an example: > http://www.shayne.me/blog/2015/2015-06-25-everything-about-kafka-part-2/ > <http://www.shayne.me/blog/2015/2015-06-25-everything-about-kafka-part-2/> > > Thanks > Eno > >> On 15 Jun 2016, at 17:21, Adrienne Kole <adrienneko...@gmail.com> wrote: >> >> Hi community, >> >> Probably it is very basic question, as I am new to Kafka Streams. >> I am trying to initialize KTable or KStream from kafka topic. However, I >> don't know how to avoid getting null keys. So, >> >> KTable<String, String> source = >> builder.stream(Serdes.String(),Serdes.String(),"t1"); >> source.print(); >> >> I enter the input on t1 topic as: >> >> one >> two >> one one >> >> and get as a result: >> >> null, (one <-null) >> null, (two <-null) >> null, (one one <-null) >> >> >> So, the key is always null. >> >> Is the key supposed to initialize after getting input from topic? If yes, >> how can I initialize key in KTable after getting input? For example in >> KStream we have KeyValueMapper that can be used to assign new keys and >> values. However, in KTable we have only ValueMappers. >> >> If not, how can I initialize the key of KTable from the input from given >> topic? >> >> >> Cheers >> Adrienne > >
signature.asc
Description: OpenPGP digital signature