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