kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Haoming Zhang <haoming.zh...@outlook.com>
Subject Partition key not working properly
Date Wed, 26 Nov 2014 01:42:45 GMT

Hi all,

I'm struggling with how to use the partition key mechanism properly. My logic is set the partition
number as 3, then  create three partition keys as "0", "1", "2", then use the partition keys
to create three KeyedMessage such as 
KeyedMessage(topic, "0", message),
KeyedMessage(topic, "1", message), 
KeyedMessage(topic, "2", message)

After this, creating a producer instance to send out all the KeyedMessage.

I expecting each KeyedMessage should enter to different partitions according to the different
partition keys, which means 
KeyedMessage(topic, "0", message) go to Partition 0,
KeyedMessage(topic, "1", message) go to Partition 1,
KeyedMessage(topic, "2", message) go to Partition 2

I'm using Kafka-web-console to watch the topic status, but the result is not like what I'm
expecting. KeyedMessage still go to partitions randomly, some times two KeyedMessage will
enter the same partition even they have different partition keys, .

Not sure whether my logic is incorrect or I didn't understand the partition key mechanism
correctly. Anyone could provides some sample code or explanation would be great!


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