Tampa
Tampa

Reputation: 78234

python kafka for consuming does not work

I can write to kafka. However, consuming does not work

kafka = KafkaClient(kafka_host_list)
consumer = SimpleConsumer(kafka,'topic-test-development','topic-test-development')

No handlers could be found for logger "kafka.conn"
Traceback (most recent call last):
  File "/home/ubuntu/workspace/feed-tests/tests/kafka_consumer.py", line 44, in <module>
    consumer = SimpleConsumer(kafka,'topic-test-development','topic-test-development')
  File "/usr/local/lib/python2.7/dist-packages/kafka/consumer/simple.py", line 126, in __init__
    auto_commit_every_t=auto_commit_every_t)
  File "/usr/local/lib/python2.7/dist-packages/kafka/consumer/base.py", line 75, in __init__
    self.fetch_last_known_offsets(partitions)
  File "/usr/local/lib/python2.7/dist-packages/kafka/consumer/base.py", line 101, in fetch_last_known_offsets
    check_error(resp)
  File "/usr/local/lib/python2.7/dist-packages/kafka/common.py", line 230, in check_error
    raise response
kafka.common.FailedPayloadsError

Upvotes: 3

Views: 3981

Answers (1)

Andy
Andy

Reputation: 347

note No handlers could be found for logger "kafka.conn"

add code for logger:

logging.basicConfig(
    format='%(asctime)s.%(msecs)s:%(name)s:%(thread)d:%(levelname)s:%(process)d:%(message)s',
    level=logging.DEBUG
)

run and output more info:

2015-07-13 15:26:32,158.158.830881119:kafka.conn:140247909795584:DEBUG:17035:Reinitializing socket connection for host01:9092 2015-07-13 15:26:32,221.221.35591507:kafka.conn:140247909795584:ERROR:17035:Unable to connect to kafka broker at host01:9092

Upvotes: 3

Related Questions