Skip to content

Instantly share code, notes, and snippets.

@zabih-alipour
Last active October 31, 2021 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zabih-alipour/817964f76d64e06789ee166028cab985 to your computer and use it in GitHub Desktop.
Save zabih-alipour/817964f76d64e06789ee166028cab985 to your computer and use it in GitHub Desktop.
Read file line by line and send to kafka topic
#! /bin/bash
cd /opt/bitnami/kafka/bin/
input="/messages/data/messages.txt"
while IFS= read -r line
do
sh kafka-console-producer.sh --bootstrap-server 127.0.0.1:9092 --topic topic_name $line
done < "$input"
@zabih-alipour
Copy link
Author

Another way to do same thing:

kafka-console-producer.sh --bootstrap-server 127.0.0.1:9092 --topic topic_name < /messages/data/messages.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment