如何解决Pykafka消费者客户需要将参数'use_greenlets'设置为true吗?
我现在写一个脚本。 我对kafka消费者中的参数“ use_greenlets”感到困惑,我认为在Consumer中没有区别。 那么,我应该在使用者模块中将'use_greenlets'设置为true吗? 谢谢。
#!/usr/bin/env python
# -*-coding:utf-8-*-
"""
c1
"""
import os.path as op
from pykafka import KafkaClient
#
hp = "127.0.0.1:9092"
client = KafkaClient(hosts=hp,use_greenlets=True)
topic = client.topics['test']
consumer = topic.get_balanced_consumer(
consumer_group="mygroup",reset_offset_on_start=False,auto_offset_reset=-1,)
fn = op.basename(__file__)
for num,message in enumerate(consumer):
if message is not None:
print(fn,message.offset,message.value.decode('utf-8'))
consumer.commit_offsets()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。