Topic Configuration¶
Note
See librdkafka CONFIGURATION for topic specific parameters
Set Partitioner¶
Tip
Default partitioner for librdkafka is consistent_random
while for Java based tools like Kafka MirrorMaker 2 or Kafka Rest Api Proxy it is murmur2_random
.
$topicConf = new \RdKafka\TopicConf();
$topicConf->setPartitioner(RD_KAFKA_MSG_PARTITIONER_MURMUR2_RANDOM);
Use a custom Partitioner¶
$topicConf = new \RdKafka\TopicConf();
$topicConf->setPartitionerCb(
function (string $key, int $partitionCount):int {
// e.g. force partition 2
return 2;
}
);