Reputation: 1013
I'm using confluent's kafka python package. I would like to add a configuration property to the Producer called partition-key-expression in spring (Java) (See this ref for more info)
The way I'm now instantiating the producer is the following:
producer = confluent_kafka.Producer({
"bootstrap.servers": <KAFKA_SERVICE_URI>,
"topic.acks": 1
})
I was wondering whether how can I add the partition-key-expression config property since I could not find it in the docs.
Upvotes: 0
Views: 935
Reputation: 191983
Spring properties are not part of the base Kafka Protocol, so they wouldn't be carried over to Python libraries.
Sounds like you're asking how to define a partitioner, e.g.
def calc_partition(key):
""" Get the partition, based on the key """
return 0
producer.produce(topic, value, key, partition=calc_partition(key))
Upvotes: 1