序列化json數(shù)據(jù)
producer = KafkaProducer(bootstrap_servers='127.0.0.1:9092', value_serializer=lambda v: json.dumps(v).encode('utf-8'))
producer.send('MY_TOPIC1', {'shouke':'kafka'})
序列化字符串key
producer = KafkaProducer(bootstrap_servers='127.0.0.1:9092', key_serializer=str.encode)
producer.send('MY_TOPIC1', b'shouke', key='strKey')
Kafka提交offset機(jī)制
鏈接:https://www.cnblogs.com/FG123/p/10091599.html?ivk_sa=1024320u