Last active
January 30, 2019 10:23
-
-
Save kavimaluskam/050e755c3b9d5c19611aa846e1f0a4dd to your computer and use it in GitHub Desktop.
Cheat sheet for Standalone Kafka Connect with Avro serialisation
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
# 0. Delete the existing topics: app-users, app-movies | |
make kafka-shell | |
kafka-topics --delete --topic app-users --zookeeper $ZK | |
kafka-topics --delete --topic app-movies --zookeeper $ZK | |
kafka-topics --create --topic app-users --partitions 2 --zookeeper $ZK --replication-factor 2 | |
kafka-topics --create --topic app-movies --partitions 2 --zookeeper $ZK --replication-factor 2 | |
exit | |
# 1. Kafka Connect with Avro serialization | |
# Enter Kafka Connect Shell Client | |
make connect-shell | |
# Kafka Connect with avro-standalone setting, connecting via postgres | |
connect-standalone dev/connect-avro-standalone.properties dev/source-postgres-incremental.properties | |
# 2. Console consumer with Avro deserialization | |
# Enter Kafka Avro Shell Client | |
make avro-shell | |
# Console Consumer with Avro deserialization | |
TOPIC=app-users | |
kafka-avro-console-consumer --bootstrap-server $BROKERS \ | |
--topic $TOPIC \ | |
--from-beginning \ | |
--property print.key=true \ | |
--property print.value=true \ | |
--property schema.registry.url=$SCHEMA_REGISTRY \ | |
--max-messages 20 | |
# Expected console-consumer output from topic: app-users | |
# null {"id":101,"first_name":"Cass","last_name":"Truss","email":"[email protected]"} | |
# null {"id":102,"first_name":"Joete","last_name":"Scowcroft","email":"[email protected]"} | |
# null {"id":103,"first_name":"Celine","last_name":"Wortley","email":"[email protected]"} | |
# null {"id":104,"first_name":"Othilia","last_name":"Gumme","email":"[email protected]"} | |
# null {"id":105,"first_name":"Maynord","last_name":"Buttrick","email":"[email protected]"} | |
# null {"id":106,"first_name":"Kendall","last_name":"Yitzovitz","email":"[email protected]"} | |
# null {"id":107,"first_name":"Tedi","last_name":"Danne","email":"[email protected]"} | |
# null {"id":108,"first_name":"Diena","last_name":"Knight","email":"[email protected]"} | |
# null {"id":109,"first_name":"Court","last_name":"Hensmans","email":"[email protected]"} | |
# null {"id":110,"first_name":"Lissi","last_name":"Andrea","email":"[email protected]"} | |
# ... | |
# Exit Docker when Kafka Connect is done | |
(Ctrl-C) | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment