I suppose the keyedMessage constructor is KeyedMessage(topic, key, message), so in your case key is "test message" + e.
Thanks, Mayuresh On Thu, Mar 5, 2015 at 9:25 AM, Zijing Guo <alter...@yahoo.com.invalid> wrote: > And I'm using kafka version 0.8.2.0 > > On Thursday, March 5, 2015 11:51 AM, Zijing Guo > <alter...@yahoo.com.INVALID> wrote: > > > Hi community,I have a 2 nodes test cluster with 2 zk instance and 2 > broker instance running and I'm experimenting kafka producer in a cluster > environment. So I create a topic "foo" with 2 partitions and replication > 1.I create a async Producer without defining partition.class (so the > partitioner will be the default one, which is > "kafka.producer.DefaultPartitioner" and I verified.) > Now since I know that there is 2 partitions for topic "foo" and I create > 1000 KeyedMessage with key = "a" > val msgs = val msgs = (1 to 1000).map(e => KeyedMessage("foo","test > message" + e, "a")) prod.send(msgs) > > In theory, "a".hashCode=97, 97 % 2 = 1. so I should expect all the message > go to broker1. However,after I send the message, from the kafka Web > console, I can see that the data is evenly distributed around the 2 brokers. > Any help will be appreciated.Thanks > > > > > -- -Regards, Mayuresh R. Gharat (862) 250-7125