Created
March 13, 2024 20:20
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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