diff --git a/_sources/vast_datastore/kafka_connect.md b/_sources/vast_datastore/kafka_connect.md index 8e93ff88..921a2a75 100644 --- a/_sources/vast_datastore/kafka_connect.md +++ b/_sources/vast_datastore/kafka_connect.md @@ -179,11 +179,14 @@ finally: ```python from kafka import KafkaProducer import json + num_of_messages = # Complete - the amount of messages to topic (can be also 1) data = {"name": "something"} producer = KafkaProducer(bootstrap_servers=':9092', value_serializer=lambda v: json.dumps(v).encode('utf-8')) + for i in range (1,num_of_messages): - producer.send('', data) + producer.send('', data) + producer.flush() print("Message sent to Kafka topic") diff --git a/vast_datastore/kafka_connect.html b/vast_datastore/kafka_connect.html index c5a1a097..75f62702 100644 --- a/vast_datastore/kafka_connect.html +++ b/vast_datastore/kafka_connect.html @@ -695,11 +695,14 @@

Creating new topic#

from kafka import KafkaProducer  
 import json  
+
 num_of_messages = # Complete - the amount of messages to topic (can be also 1)  
 data = {"name": "something"}  
 producer = KafkaProducer(bootstrap_servers='<YOUR_CLIENT_IP>:9092', value_serializer=lambda v: json.dumps(v).encode('utf-8'))  
+
 for i in range (1,num_of_messages):  
-    producer.send('<YOUR_TOPIC_NAME>', data)  
+    producer.send('<YOUR_TOPIC_NAME>', data)
+    
 producer.flush()
 
 print("Message sent to Kafka topic")