You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

producer_stop.py 609B

2 years ago
2 years ago
2 years ago
123456789101112131415161718
  1. # import sys
  2. # sys.path.extend(["..", "../util"])
  3. # from util.AliyunSdk import AliyunVodSdk
  4. # from concurrency.CommonThread import Common
  5. from kafka import KafkaProducer
  6. import json
  7. import threading
  8. topicName = 'dsp-alg-online-tasks'
  9. eBody = {
  10. "request_id": "d4c909912ac741ce81ccef03fd1b2ec45",
  11. "command": "stop"
  12. }
  13. producer = KafkaProducer(bootstrap_servers=['192.168.11.242:9092'],
  14. value_serializer=lambda m: json.dumps(m).encode('utf-8'))
  15. future = producer.send(topicName, key=b'd4c909912ac741ce81ccef03fd1b2ec45', value=eBody)
  16. result = future.get(timeout=10)
  17. print(result)