This example consists of 2 parts:
- A collection of Docker Compose services
roach-source- single CockroachDB node serving as CDC sourceroach-destination- single CockroachDB node serving as CDC destinationzookeeper- required component of Confluent Kafka instancekafka- Confluent Kafka instance that stores CDC data
- Two Spring Boot applications... one for inserting data into the
sourceCockroachDB instance (the producer) and one for reading from Kafka and writing to thedestinationCockroachDB instance (the consumer).
- Execute
./up.sh CRDB_ORG_NAME CRDB_LICENSE_KEYwhereCRDB_ORG_NAMEis your CRDB Enterprise License Org andCRDB_LICENSE_KEYis your CRDB Enterprise License Key. For now, executingdocker-compose updirectly is not supported. This command will start the required Docker containers. - You can verify that each CockroachDB instance is running by visiting the following URLS:
- Source Cockroach UI - http://localhost:8080
- Destination Cockroach UI - http://localhost:8081
- Start the
consumerSpring Boot application. Theconsumerapplication will read from Kafka and populate thedestinationdatabase once theproducerbegins generating data../mvnw -pl consumer -am spring-boot:run - Start the
producerSpring Boot application. This will slowly load data into thesourcedatabase where theCHANGEFEEDis enabled. Once data is written to thesourcedatabase theCHANGEFEEDwill publish data to Kafka and be read by theconsumerapplication../mvnw -pl producer -am spring-boot:run - When you are done, you can stop all services with
down.sh. To do a full system prune runprune.sh.
Use this to show running jobs in roach-source cluster
docker-compose exec roach-source /cockroach/cockroach sql --insecure --execute="SHOW JOBS;"Use this to see data in Kafka topic
docker-compose exec kafka /usr/bin/kafka-console-consumer --bootstrap-server=localhost:9092 --from-beginning --topic=source_tableUse this to view data in the soucre database
docker-compose exec roach-source /cockroach/cockroach sql --insecure --database source --execute="select count(*) from source_table;"Use this to verify data has been loaded into the destination database
docker-compose exec roach-destination /cockroach/cockroach sql --insecure --database destination --execute="select count(*) from destination_table;"List all Kafka topics
docker-compose exec kafka /usr/bin/kafka-topics --list --zookeeper zookeeper:2181