confluent-kafka-python icon indicating copy to clipboard operation
confluent-kafka-python copied to clipboard

Consumer poll() return None if the value of the message is None

Open hrchu opened this issue 4 years ago • 1 comments

According to the doc, poll() only returns None in the timeout situation. I notice that poll() also returns None if the value of the message is None. Is this an expected behavior?

p = Producer({'bootstrap.servers': 'mybroker1,mybroker2'})
p.produce('mytopic', None)
p.flush()

c = Consumer({
    'bootstrap.servers': 'mybroker',
    'group.id': 'mygroup',
    'auto.offset.reset': 'earliest'
})
low, high = c.get_watermark_offsets(TopicPartition('mytopic', 0), timeout=TIMEOUT)
c.assign([TopicPartition('mytopic', 0, high - 1)])
c.poll(timeout=TIMEOUT) => Get None instead of a Message object with None as value

hrchu avatar Nov 11 '21 01:11 hrchu

Hi @hrchu, thanks for asking.

I think Poll returns None means it doesn't get anything. I tried on my local, what I got is Message Object even though the message value is None:

tests % python consumer1270.py
<cimpl.Message object at 0x7faa90014240>

I saw your producer doesn't have a delivery report, not sure if your message is delivered or not.

jliunyu avatar Mar 21 '22 21:03 jliunyu

I notice that poll() also returns None if the value of the message is None. Is this an expected behavior?

no. something else is going on, that should never happen.

mhowlett avatar Oct 25 '22 22:10 mhowlett