You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by "Yu, Libo " <li...@citi.com> on 2013/05/09 16:44:05 UTC
key used by producer
Hi,
I am looking at the example producer code for kafka 0.8.
I notice it is possible to specify a key when creating
KeyedMessage. This key will be used for assigning the
message to some partition. I wonder if the key will be
received by the consumer. Thanks.
Libo
Re: key used by producer
Posted by Jun Rao <ju...@gmail.com>.
Yes, our consumer iterator returns MessageAndMetadata. You can do
consumerIterator.next().key() to get the key.
Thanks,
Jun
On Thu, May 9, 2013 at 7:44 AM, Yu, Libo <li...@citi.com> wrote:
> Hi,
>
> I am looking at the example producer code for kafka 0.8.
> I notice it is possible to specify a key when creating
> KeyedMessage. This key will be used for assigning the
> message to some partition. I wonder if the key will be
> received by the consumer. Thanks.
>
>
> Libo
>
>
Re: key used by producer
Posted by David Arthur <mu...@gmail.com>.
Yes, I'm pretty sure keys are now retained with the message and returned
in the consumer.
In the Java/Scala client, ConsumerIterator returns a MessageAndMetadata
which includes key, message, topic, partition, and offset
-David
On 5/9/13 10:44 AM, Yu, Libo wrote:
> Hi,
>
> I am looking at the example producer code for kafka 0.8.
> I notice it is possible to specify a key when creating
> KeyedMessage. This key will be used for assigning the
> message to some partition. I wonder if the key will be
> received by the consumer. Thanks.
>
>
> Libo
>
>