kafka封装
Project description
pykafka_util
- pykafka_util.py
from pykafka_util.pykafka_util import KafkaManager
kafka_host = f'127.0.0.1:9094'
topic = 'py_kafka'
consumer = 'test'
message = {
"send_type": "sync_send",
"name": "lady_killer",
"age": 18
}
manager = KafkaManager(kafka_host)
v = bytes('{}'.format(json.dumps(message)), 'utf-8')
# 生产消息
manager.produce(topic=topic, value=v)
# 消费消息
consumed_messages = manager.consume(topic=topic, group_id=consumer, num_messages=10)
for data in consumed_messages:
logging.info(f"消费数据:{data}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pykafka_util-1.0.1.tar.gz
(3.3 kB
view details)
Built Distribution
File details
Details for the file pykafka_util-1.0.1.tar.gz
.
File metadata
- Download URL: pykafka_util-1.0.1.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecd1bfa18d4983d3eec51c37feed168a5958c7e1863ff8621b92b24cc6f58b1c |
|
MD5 | e7df7739daeb8bdd034ea53659cb65b9 |
|
BLAKE2b-256 | 6e06be4930efad5c9d5b38b0e3ad9c9c1562e924cd862d3e49586f1ee6739881 |
File details
Details for the file pykafka_util-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pykafka_util-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb12d4d179b9bcffd6c5b5e637af5f2adc0010d906a52a614d6f3563e15c762d |
|
MD5 | 62055a2d7bc5d98b25c94c083e858f1d |
|
BLAKE2b-256 | 0a7ebb5f97757a7e973f54f289d6fb1757dfc7cfec692bbac8128edb8a1615af |