Skip to content

Instantly share code, notes, and snippets.

@un4ckn0wl3z
Created August 8, 2023 07:58
Show Gist options
  • Save un4ckn0wl3z/623eaf71c69cda39c48a7d7ec0870308 to your computer and use it in GitHub Desktop.
Save un4ckn0wl3z/623eaf71c69cda39c48a7d7ec0870308 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Define the Kafka broker and topic
BROKER_LIST="localhost:9092"
TOPIC="mfaf.exampleTopic"
# Loop to simulate load test
while true; do
# Generate some random JSON data and save it to a file
# echo "{\"key\": \"value\"}" > m.json
# Use kafka-console-producer to send the JSON data to the Kafka topic
kafka-console-producer --broker-list $BROKER_LIST --topic $TOPIC < m.json
# Optional: You can add a delay between sending messages to control the load rate
# sleep 1 # Add a 1-second delay
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment