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.

12 line
458B

  1. from kafka import KafkaProducer
  2. import json
  3. topicName = 'alg_online_tasks'
  4. eBody = {"request_id": "16446e0d79fb4497b390d1a7f49f3079","command":"stop"}
  5. producer = KafkaProducer(bootstrap_servers=[
  6. 'localhost:9092'],
  7. value_serializer=lambda m: json.dumps(m).encode('utf-8'))
  8. future = producer.send(topicName, key=b'16446e0d79fb4497b390d1a7f49f3079', value=eBody)
  9. result = future.get(timeout=10)
  10. print(result)