Created
September 12, 2018 02:46
-
-
Save hhstore/66de3b0f8cdfdd5e67ecff39cf1f7d73 to your computer and use it in GitHub Desktop.
kafka: producer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kafka import KafkaConsumer, KafkaProducer | |
# pip install kafka-python | |
SERVERS = ['localhost:9092', ] | |
def produce(): | |
p = KafkaProducer(bootstrap_servers=SERVERS) | |
future = p.send("topic1", key=b"key1", value=b"v1", partition=0) | |
result = future.get(timeout=10) | |
print(result) | |
if __name__ == '__main__': | |
produce() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
consumer: