공부
[Python] Kafka Serializer
승가비
2022. 5. 14. 20:51
728x90
>>> # Serialize string keys
>>> producer = KafkaProducer(key_serializer=str.encode)
>>> producer.send('flipflap', key='ping', value=b'1234')
>>> # Serialize json messages
>>> import json
>>> producer = KafkaProducer(value_serializer=lambda v: json.dumps(v).encode('utf-8'))
>>> producer.send('fizzbuzz', {'foo': 'bar'})
https://kafka-python.readthedocs.io/en/master/index.html?highlight=key_serializer#kafkaproducer
kafka-python — kafka-python 2.0.2-dev documentation
Python client for the Apache Kafka distributed stream processing system. kafka-python is designed to function much like the official java client, with a sprinkling of pythonic interfaces (e.g., consumer iterators). kafka-python is best used with newer brok
kafka-python.readthedocs.io
728x90