Skip to content

Consumer poll() does not always return #18

Closed
@mikesparr

Description

@mikesparr

I'm running into an odd scenario with Consumer class implementation where sometimes the poll() return is null or empty. I would expect this to be one of the object with message, or object with error (sometimes just EOF for partition), but never empty or null?

Here is my code and out of 25,000 messages in topic, just under 2,000 warnings in log that poll() returned no msg object. What conditions would this occur or did I implement incorrectly below?

                while running:
                    try:
                        msg = c.poll()
                        if msg:
                            if not msg.error():
                                processor(msg)
                            elif msg.error().code() == kafka.KafkaError._PARTITION_EOF:
                                # End of partition event
                                logger.debug( "{} [{}] reached end at offset {}".format(
                                                msg.topic(), msg.partition(), msg.offset()) )
                                logger.debug( "Consumed [{}] records so far (reached end of offset)".format(self.consumed) )
                            else:
                                logger.debug( "Unknown error [{}] during polling.".format(msg.error()) )
                                raise kafka.KafkaException(msg.error())

                            self.consumed += 1
                            if (self.consumed % 100) == 0:
                                logger.debug( "Consumed [{}] records since startup.".format(self.consumed) )
                        else:
                            logger.warn( "No message object returned on poll() [{}]".format(msg) )

                    except Exception, e:
                        logger.warn( "Error polling messages [{}]".format(str(e)) )
                        logger.debug( traceback.format_exc() )
                        # we do not stop loop because some polling errors anticipated
                        # https://github.com/confluentinc/confluent-kafka-python/issues/12
                # end while running loop

In logs:

2016-07-12 15:09:25,331 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,332 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,342 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,343 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,343 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,343 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,343 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,343 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,343 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,343 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,343 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,344 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,344 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,344 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,344 - DEBUG - stream_consumer.pyc - Consumed [24800] records since startup.
2016-07-12 15:09:25,344 - WARNING - stream_consumer.pyc - No message object returned on poll()
2016-07-12 15:09:25,345 - WARNING - stream_consumer.pyc - No message object returned on poll()

Metadata

Metadata

Assignees

No one assigned

    Labels

    component:librdkafkaFor issues tied to the librdkfka elements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions