Mattias Petter Johansson
Mattias Petter Johansson

Reputation: 1074

Does the 0.8.2 Kafka Producer manage partitioning for you?

I have a hard time understanding what (if anything) is the equivalent of the 0.8.0 "partitioner.class" configuration property in the new 0.8.2 producer.

Upvotes: 0

Views: 589

Answers (1)

user2720864
user2720864

Reputation: 8161

I believe form 0.8.2 they have introduced org.apache.kafka.clients.producer.ProducerRecord<K,V> which takes a topic name an optional partition number, and an optional key and value. You can typically use it like

    ProducerRecord<String,String> producerRecord = new ProducerRecord<String,String>(topic, key, value);

From the doc

If a valid partition number is specified that partition will be used when sending the record. If no partition is specified but a key is present a partition will be chosen using a hash of the key. If neither key nor partition is present a partition will be assigned in a round-robin fashion.

Upvotes: 3

Related Questions