Skip to content

Instantly share code, notes, and snippets.

@dalelane
Created March 13, 2024 20:20
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 dalelane/390176f3a1a4b29abd2b908e4b5c514e to your computer and use it in GitHub Desktop.
Save dalelane/390176f3a1a4b29abd2b908e4b5c514e to your computer and use it in GitHub Desktop.
Using the Event Streams Producer API to produce data from a file, one message per line
#!/bin/sh
# the URL from Step 1
URL=https://my-kafka-cluster-ibm-es-recapi-external-event-automation.apps.15eb31a112f5c312116f22c1.cloud.techzone.ibm.com
# the credentials from Step 2
USERNAME=demo-username
PASSWORD=tfmA896q8l3rCcbqa15k4NOcbn8Zm5ir
# the file you created in Step 3
TEST_DATA_FILE=data.json
# the topic to produce messages to
TOPIC=MYTOPIC
while read line; do
curl \
--silent \
-X POST \
-H "Content-Type: text/plain" \
-k \
--data "$line" \
-u $USERNAME:$PASSWORD \
$URL/topics/$TOPIC/records > /dev/null
done < $TEST_DATA_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment