本文整理汇总了Python中kafka.SimpleConsumer.max_buffer_size方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleConsumer.max_buffer_size方法的具体用法?Python SimpleConsumer.max_buffer_size怎么用?Python SimpleConsumer.max_buffer_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kafka.SimpleConsumer
的用法示例。
在下文中一共展示了SimpleConsumer.max_buffer_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: consume
# 需要导入模块: from kafka import SimpleConsumer [as 别名]
# 或者: from kafka.SimpleConsumer import max_buffer_size [as 别名]
def consume(kafka_host):
kafka = KafkaClient(kafka_host)
consumer = SimpleConsumer(kafka, 'fetcher', cfg['kafka']['pages'])
producer = SimpleProducer(kafka)
consumer.max_buffer_size=20*1024*1024
for msg in consumer:
page = json.loads(msg.message.value)
process(page, producer)
kafka.close()
示例2: len
# 需要导入模块: from kafka import SimpleConsumer [as 别名]
# 或者: from kafka.SimpleConsumer import max_buffer_size [as 别名]
from kafka import KafkaClient, SimpleConsumer
from sys import argv
MIN_NUM_ARGS = 4
if (len(argv) < MIN_NUM_ARGS):
print "Wrong number of arguments: ", len(argv)
print "Usage: python simple-consumer <broker-address> <topic-name> <consumer-group-id>"
exit(1)
kafkaClientAddress = argv[1]
topicName = argv[2]
consumerGroupId = argv[3]
kafkaClient = KafkaClient(kafkaClientAddress)
consumer = SimpleConsumer(kafkaClient, consumerGroupId, topicName)
consumer.max_buffer_size=0
consumer.seek(0,2)
for message in consumer:
print("OFFSET: "+str(message[0])+"\t MSG: "+str(message[1][3]))