0

我需要设置卡夫卡生产者发送500 msgs在一个批次不是味精通过味精,但批量导入。我检查https://github.com/dpkp/kafka-python/issues/479并试图producer.send_messages(topic, *message) 但它失败,错误:汇合卡夫卡Python库配置生产者批量味精

>  producer.send_messages('event_connector_mt', *load_entries) 
E  AttributeError: 'cimpl.Producer' object has no attribute 'send_messages' 

我也试图通过它像 producer.produce(topic, *message) 失败:

 producer.produce('event_connector_mt', *load_entries) 
E  TypeError: function takes at most 8 arguments (501 given) 

所以我挖多了,发现了,我有设置生产者配置的类型是异步和batch.size比默认,但是当我尝试像这样配置:

from confluent_kafka import Consumer, Producer  

producer = Producer(**{'bootstrap.servers': KAFKA_BROKERS, 
         'queue.buffering.max.messages': 1000000, 
         'batch.num.messages': 500, 
         'batch.size': 19999, 
         'producer.type': 'async' 
         }) 

失败:

E  KafkaException: KafkaError{code=_INVALID_ARG,val=-186,str="No such configuration property: "producer.type""} 

同样的错误了batch.size 你能品脱我在哪里,以及我如何设置异步和批量大小或任何其他方式批量封邮件传递给卡夫卡0.9.3.1

回答

1

所有生产者默认都是异步的。 Producer.type和batch.size不受底层librdkafka库的支持。

因此,请使用可用配置batch.num.messages或message.max.bytes。