Last active
August 6, 2018 13:50
-
-
Save gbersac/84cae211059d1ddc234eb1b8d5c8936b to your computer and use it in GitHub Desktop.
kafka producer / listener
This file contains hidden or 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 | |
if [ $# -lt 2 ]; then | |
echo "$0 container topic" | |
exit 1 | |
fi | |
# listener | |
CONTAINER="$1" | |
TOPIC="$2" | |
docker exec -it "$CONTAINER" kafka-console-consumer.sh --topic "$TOPIC" --bootstrap-server localhost:`docker port "$CONTAINER" | cut -d ':' -f 2` | |
# producer | |
CONTAINER="$1" | |
TOPIC="$2" | |
docker exec -it "$CONTAINER" kafka-console-producer.sh --topic "$TOPIC" --property parse.key=true --property key.separator=, --broker-list localhost:`docker port "$CONTAINER" | cut -d ':' -f 2` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment