0

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.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
room13
  • 883
  • 2
  • 10
  • 26

1 Answers1

1

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))
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245