티스토리 뷰
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
'공부' 카테고리의 다른 글
[Avro] schema (multiple record, null default of record) & convertor (0) | 2022.05.14 |
---|---|
[Docker] naming rule: `docker/asdf.Dockerfile` (0) | 2022.05.14 |
[Slack] send message (0) | 2022.05.14 |
[Slack] https://slack.com/api/users.lookupByEmail (0) | 2022.05.08 |
[gradle] from maven `implementation(project(":data-core"))` (0) | 2022.05.08 |
댓글