kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ewen Cheslack-Postava <e...@confluent.io>
Subject Re: No key specified when sending the message to Kafka
Date Wed, 24 Jun 2015 03:53:26 GMT
It does balance data, but is sticky over short periods of time (for some
definition of short...). See this FAQ for an explanation:
https://cwiki.apache.org/confluence/display/KAFKA/FAQ#FAQ-Whyisdatanotevenlydistributedamongpartitionswhenapartitioningkeyisnotspecified
?

This behavior has been changed in the new producer to work the way you
expected, and can be overridden by providing your own Partitioner interface.

On Tue, Jun 23, 2015 at 8:28 PM, bit1129@163.com <bit1129@163.com> wrote:

> I have the following code snippet that use Kafka Producer to send
> message(No key is specified in the KeyedMessage):
> val data = new KeyedMessage[String, String](topicName, msg);
> Kafka_Producer.send(data)
>
> Kafka_Producer is an instance of kafka.producer.Producer.
>
>
> With above code, I observed that the message sent to kafka is not
> partitioned(That is, all the messages are pushed to partition 0). If I give
> the message a key, they it can be partitioned across the topic.
>
> So, my question is: If no key is provided in the message , will Kafka
> producer not automatically partition the message with some built-in
> balancing algorithm?
>
> Thanks
>
>
>
>
>
>
>
> bit1129@163.com
>



-- 
Thanks,
Ewen

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