kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrienne Kole <adrienneko...@gmail.com>
Subject Re: About null keys
Date Thu, 16 Jun 2016 10:58:48 GMT
Thank you for your answers. I was trying to give input to topic from
console. Therefore, when I consume the message on kafka streams, I got
values with null keys. When I used producer classes of kafka  as a
Producer, I managed to solve the problem.

Thank you for your guidance.

Adrienne.

On Thu, Jun 16, 2016 at 10:57 AM, Matthias J. Sax <matthias@confluent.io>
wrote:

> 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 <adriennekole1@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
> >
> >
>
>

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