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
source
CockroachDB instance (the producer) and one for reading from Kafka and writing to thedestination
CockroachDB instance (the consumer).
- Execute
./up.sh CRDB_ORG_NAME CRDB_LICENSE_KEY
whereCRDB_ORG_NAME
is your CRDB Enterprise License Org andCRDB_LICENSE_KEY
is your CRDB Enterprise License Key. For now, executingdocker-compose up
directly 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
consumer
Spring Boot application. Theconsumer
application will read from Kafka and populate thedestination
database once theproducer
begins generating data../mvnw -pl consumer -am spring-boot:run
- Start the
producer
Spring Boot application. This will slowly load data into thesource
database where theCHANGEFEED
is enabled. Once data is written to thesource
database theCHANGEFEED
will publish data to Kafka and be read by theconsumer
application../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_table
Use 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