0

Trying to extract the tuple values from TopicPartition like topic, partition, offset etc. Could not locate a helper method. Added code snippet below

from confluent_kafka import DeserializingConsumer

conf = {
    'bootstrap.servers': 'bootstrap_server',
    <other configurations>
}

consumer = DeserializingConsumer(conf)
deserializing_consumer.subscribe([topic])

while True:
    
    data = deserializing_consumer.poll(10)
    for assignment in deserializing_consumer.assignment():
        print(assignment)

The print statement only emits the output like the below, but would like to extract key, values individually. TopicPartition is not iterable as well. Can you please provide some pointers?

TopicPartition{topic=test-topic,partition=%I32d,offset=%s,leader_epoch=%s,error=%s}

python version 3.11.0

Kafka broker version 2.5.0

confluent-kafka==2.1.1

madmatrix
  • 205
  • 1
  • 4
  • 12

0 Answers0