Commit aded7896 authored by 张彦钊's avatar 张彦钊

change test file

parent ec4c353c
......@@ -6,21 +6,27 @@ import pickle
import time
from kafka import KafkaProducer
def on_send_success():
print("succeed")
return 1
def on_send_error():
print("fail")
return 0
if __name__ == "__main__":
producer = KafkaProducer(bootstrap_servers=['172.16.44.25:9092'],key_serializer=lambda k: pickle.dumps(k),value_serializer=lambda v: pickle.dumps(v))
print("hajs")
producer.send(topic = "test_topic", key = "hello", value = "world")\
.add_callback(on_send_success).add_errback(on_send_error)
producer.flush()
producer.close()
future = producer.send(topic= "test_topic", key = "hello", value = "world")
try:
record_metadata = future.get(timeout=10)
print(12)
except kafka_errors as e:
print(str(e))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment