Partitioner Contract — Partitioning Strategy

Partitioner is the contract of partitioners (aka partitioning strategies) that can compute the partition for a producer record.

Partitioner is also a Configurable that can be created by reflection and need to take configuration parameters.

Note
DefaultPartitioner is the one and only known implementation of the Partitioner Contract in Apache Kafka.
Table 1. Partitioner Contract
Method Description

close

void close()

Closes the partitioner

partition

int partition(
  String topic,
  Object key,
  byte[] keyBytes,
  Object value,
  byte[] valueBytes,
  Cluster cluster)

Computes the partition ID for a record (described by a topic, a key, a value, the serialized key and value, and the Cluster metadata)

Used when KafkaProducer is requested to compute the partition for a ProducerRecord

results matching ""

    No results matching ""