Search code examples
apache-kafkakafka-consumer-apikafka-python

Is there a way to specify the isolation level in Kafka-Python consumer API?


I am trying to write a consumer using Kafka-Python ensuring the exactly once semantics. The messages in the partitions are produced using a transaction aware producer. I read from the Kafka docs that I should specify the isolation_level to be read_committed so it would read only the committed messages. The thing is I don't see anywhere in the documentation of the Python client on how to specify this isolation_level. Any ideas on how to make my consumer read just the committed messages?

Expected result: Just get the transation committed messages Actual Result: The consumer reads even the aborted messages that look like this

ConsumerRecord(topic='tweets', partition=0, offset=504, timestamp=1557007360598, timestamp_type=0, key=b'\x00\x00\x00\x01', value='"\\u0000\\u0000\\u0000\\u0000\\u0000\\u0000"', checksum=None, serialized_key_size=4, serialized_value_size=6)

Solution

  • According to this issue, isolation.level=read_committed is not supported from kafka-python yet.