Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- ENV=$1
- topic=$2
- from_beginning=$3
- print_key=${4:-true}
- schema_registry_prod=<>
- schema_registry_dev=<>
- bootstrap_server_prod=<>
- bootstrap_server_dev=<>
- if [[ -z $topic ]]; then
- echo "Topic needs to be specified"
- exit 1
- fi
- ### CHECK IF TOPIC IS SUPPLIED
- echo "Looking up topic: " $topic
- if [ $ENV == 'prod' ]
- then
- echo "Going for prod"
- schema_registry=schema_registry_prod
- bootstrap_server=bootstrap_server_prod
- else
- echo "Going for dev"
- schema_registry=schema_registry_dev
- bootstrap_server=bootstrap_server_dev
- fi
- echo "Print key: "$print_key
- if [[ $from_beginning ]]; then
- echo "From beginning is true"
- sh kafka-avro-console-consumer \
- --bootstrap-server $bootstrap_server \
- --topic $topic \
- --property schema.registry.url=$schema_registry \
- --property print.timestamp=true \
- --property print.key=$print_key \
- --from-beginning
- else
- sh kafka-avro-console-consumer \
- --bootstrap-server $bootstrap_server \
- --topic $topic \
- --property schema.registry.url=$schema_registry \
- --property print.key=$print_key \
- --property print.timestamp=true
- fi
Add Comment
Please, Sign In to add comment