You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Zijing Guo <al...@yahoo.com.INVALID> on 2015/02/08 01:17:45 UTC

Can't send a keyedMessage to brokers with partitioner.class=kafka.producer.DefaultPartitioner

Hi,I have a 2 nodes kafka cluster with 2 instances of brokers and zookeepers. And then I create a topic kafka-test with 2 partitions and replication-factor =2. My producer config is:                      {"partitioner.class" "kafka.producer.DefaultPartitioner"                      "metadata.broker.list" "172.32.1.248:9092,172.32.1.251:9092"                      "request.required.acks" "1"}
So for the DefaultPartitoner, it will calculate and hashvalue and divide by the num_partiton to decide which partition the data it will go, so I create my keyedMessageval key-msg = KeyedMessage("kafka-test","a","test message!")prod.send(key-msg)
"a"'s hashValue is 97 and 97 % 2 = 1, so the data should go to partition1. However, the data did't get send to the brokers (I have a console consumer running that didn't receive any message from this topic). If I create the key-msg without the key, it works fine
val key-msg = KeyedMessage("kafka-test","test message!")prod.send(key-msg)
Am I using the key wrong or anything?ThanksEdwin

Re: Can't send a keyedMessage to brokers with partitioner.class=kafka.producer.DefaultPartitioner

Posted by Zijing Guo <al...@yahoo.com.INVALID>.
Anyone would like to give some help? Can't send a keyedMessage to brokers with partitioner.class=kafka.producer.DefaultPartitioner

|   |
|   |  |   |   |   |   |   |
| Can't send a keyedMessage to brokers with partitioner.cl...I have a 2 nodes kafka cluster with 2 instances of brokers and zookeepers. And then I create a topic kafka-test with 2 partitions and replication-factor =2. My prod... |
|  |
| View on stackoverflow.com | Preview by Yahoo |
|  |
|   |

   

     On Sunday, February 8, 2015 4:18 AM, Zijing Guo <al...@yahoo.com.INVALID> wrote:
   

 Hi,I have a 2 nodes kafka cluster with 2 instances of brokers and zookeepers. And then I create a topic kafka-test with 2 partitions and replication-factor =2. My producer config is:                      {"partitioner.class" "kafka.producer.DefaultPartitioner"                      "metadata.broker.list" "172.32.1.248:9092,172.32.1.251:9092"                      "request.required.acks" "1"}
So for the DefaultPartitoner, it will calculate and hashvalue and divide by the num_partiton to decide which partition the data it will go, so I create my keyedMessageval key-msg = KeyedMessage("kafka-test","a","test message!")prod.send(key-msg)
"a"'s hashValue is 97 and 97 % 2 = 1, so the data should go to partition1. However, the data did't get send to the brokers (I have a console consumer running that didn't receive any message from this topic). If I create the key-msg without the key, it works fine
val key-msg = KeyedMessage("kafka-test","test message!")prod.send(key-msg)
Am I using the key wrong or anything?ThanksEdwin