How to check which partition is a key assign to in kafka?

后端 未结 2 1445
滥情空心
滥情空心 2021-01-06 07:32

I am trying to debug a issue for which I am trying to prove that each distinct key only goes to 1 partition if the cluster is not rebalancing.

So I was wondering for

2条回答
  •  一个人的身影
    2021-01-06 08:19

    when you send message, Partitions are determined by the following classes

    https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/producer/internals/DefaultPartitioner.java

    If you want change logics, implement org.apache.kafka.clients.producer.Partitioner interface and, set ProduceConfig's 'partitioner.class'

    reference docuement : https://kafka.apache.org/documentation/#producerconfigs

提交回复
热议问题