Working with kafka
// CREATE TOPIC
$ kafka-topics.sh \
--zookeeper localhost:2181 \
--create \
--partitions 3 \
--replication-factor 2 \
--topic test
// DESCRIBE TOPIC
$ kafka-topics.sh \
--zookeeper localhost:2181 \
--topic test \
--describe
// LIST TOPICS
$ kafka-topics.sh \
--zookeeper localhost:2181 \
--list
returns:
test
// Create a Message
$ kafka-console-producer.sh \
--broker-list localhost:9092 \
--topic test
Test Message 1
Test Message 2
^C
// Receive a Message
$ kafka-console-consumer.sh \
--bootstrap-server localhost:9092 \
--topic test \
--from-beginning
^C
Send a message in a json format
$ vi message.json
{
"distributionID":"TB-AARTool-30",
"senderID":"TB-AARTool",
"dateTimeSent":1635405698193,
"dateTimeExpires":1635405698193,
"distributionStatus":"System",
"distributionKind":"Request"
}
$ kafka-console-producer.sh --broker-list localhost:9092 --topic test < ./message.json
// https://stackoverflow.com/questions/69753326/how-can-i-send-key-value-to-kafka-with-kafkaconsoleproducer-without-it-beind-e
$ kafka-console-producer.sh --broker-list localhost:9092 --topic test --property "parse.key=true" --property "key.separator=;" < ./message.json