Skip to content

Instantly share code, notes, and snippets.

@OneCricketeer
Created January 30, 2018 23:44
Show Gist options
  • Save OneCricketeer/d9179fc010ffa4bf33cf30dd3db29ee0 to your computer and use it in GitHub Desktop.
Save OneCricketeer/d9179fc010ffa4bf33cf30dd3db29ee0 to your computer and use it in GitHub Desktop.
Get the embedded schema IDs of Confluent KafkaAvroSerializer
while :; do kafka-console-consumer --topic $TOPIC --bootstrap-server $KAFKA --max-messages=1 2>/dev/null | hexdump | head -n 1 | cut -d' ' -f 5,6 | tr -ds '[[:space:]]' '' | { IFS= read -r schemaId; printf '%s\n' "$((16#${schemaId}))"; }; done
@OneCricketeer
Copy link
Author

OneCricketeer commented Jan 30, 2018

Expanded version

while :; 
do 
  kafka-console-consumer --topic $TOPIC --bootstrap-server $KAFKA --max-messages=1 2>/dev/null \
    | hexdump | head -n 1 \
    | cut -d' ' -f 5,6 | tr -ds '[[:space:]]' '' \
    | { IFS= read -r schemaId; printf '%s\n' "$((16#${schemaId}))"; }; 
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment