Skip to content

Commit

Permalink
Create data_ingestion.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jun 1, 2024
1 parent 0999922 commit f9b4ee6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions data_ingestion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import json
from kafka import KafkaProducer

KAFKA_TOPIC = "data_ingestion"

def ingest_data(data):
producer = KafkaProducer(bootstrap_servers="localhost:9092",
value_serializer=lambda v: json.dumps(v).encode("utf-8"))
producer.send(KAFKA_TOPIC, data)
producer.flush()

0 comments on commit f9b4ee6

Please sign in to comment.