Guest User

Untitled

a guest
Jul 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. ENV=$1
  4. topic=$2
  5. from_beginning=$3
  6. print_key=${4:-true}
  7. schema_registry_prod=<>
  8. schema_registry_dev=<>
  9.  
  10. bootstrap_server_prod=<>
  11. bootstrap_server_dev=<>
  12.  
  13. if [[ -z $topic ]]; then
  14. echo "Topic needs to be specified"
  15. exit 1
  16. fi
  17.  
  18. ### CHECK IF TOPIC IS SUPPLIED
  19.  
  20. echo "Looking up topic: " $topic
  21.  
  22. if [ $ENV == 'prod' ]
  23. then
  24. echo "Going for prod"
  25. schema_registry=schema_registry_prod
  26. bootstrap_server=bootstrap_server_prod
  27. else
  28. echo "Going for dev"
  29. schema_registry=schema_registry_dev
  30. bootstrap_server=bootstrap_server_dev
  31. fi
  32.  
  33. echo "Print key: "$print_key
  34.  
  35. if [[ $from_beginning ]]; then
  36. echo "From beginning is true"
  37. sh kafka-avro-console-consumer \
  38. --bootstrap-server $bootstrap_server \
  39. --topic $topic \
  40. --property schema.registry.url=$schema_registry \
  41. --property print.timestamp=true \
  42. --property print.key=$print_key \
  43. --from-beginning
  44. else
  45. sh kafka-avro-console-consumer \
  46. --bootstrap-server $bootstrap_server \
  47. --topic $topic \
  48. --property schema.registry.url=$schema_registry \
  49. --property print.key=$print_key \
  50. --property print.timestamp=true
  51. fi
Add Comment
Please, Sign In to add comment