{"id":26499691,"url":"https://github.com/cockroachlabs-field/cdc-example","last_synced_at":"2025-07-12T04:35:11.942Z","repository":{"id":39343552,"uuid":"160048209","full_name":"cockroachlabs-field/cdc-example","owner":"cockroachlabs-field","description":"Simple example of CockroachDB CDC using Spring Boot and Kafka","archived":false,"fork":false,"pushed_at":"2024-11-13T22:18:02.000Z","size":167,"stargazers_count":3,"open_issues_count":4,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-06T07:37:12.719Z","etag":null,"topics":["change-data-capture","cockroachdb","docker-compose","kafka","spring-boot","zookeeper"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cockroachlabs-field.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-02T13:06:43.000Z","updated_at":"2024-11-13T22:18:07.000Z","dependencies_parsed_at":"2024-11-13T23:30:20.709Z","dependency_job_id":null,"html_url":"https://github.com/cockroachlabs-field/cdc-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cockroachlabs-field/cdc-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fcdc-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fcdc-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fcdc-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fcdc-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cockroachlabs-field","download_url":"https://codeload.github.com/cockroachlabs-field/cdc-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fcdc-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264939615,"owners_count":23686208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["change-data-capture","cockroachdb","docker-compose","kafka","spring-boot","zookeeper"],"created_at":"2025-03-20T15:18:45.314Z","updated_at":"2025-07-12T04:35:11.623Z","avatar_url":"https://github.com/cockroachlabs-field.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CockroachDB CDC Example\n\nBased on https://www.cockroachlabs.com/docs/stable/change-data-capture.html#create-a-changefeed-connected-to-kafka\n\nThis example consists of 2 parts:\n* A collection of Docker Compose services\n    * `roach-source` - single CockroachDB node serving as CDC source\n    * `roach-destination` - single CockroachDB node serving as CDC destination\n    * `zookeeper` - required component of Confluent Kafka instance\n    * `kafka` - Confluent Kafka instance that stores CDC data\n* Two Spring Boot applications... one for inserting data into the `source` CockroachDB instance (the producer) and one for reading from Kafka and writing to the `destination` CockroachDB instance (the consumer).\n\n## How to Run\n\n1) Execute `./up.sh CRDB_ORG_NAME CRDB_LICENSE_KEY` where `CRDB_ORG_NAME` is your CRDB Enterprise License Org and `CRDB_LICENSE_KEY` is your CRDB Enterprise License Key.  For now, executing `docker-compose up` directly is not supported.  This command will start the required Docker containers.  \n2) You can verify that each CockroachDB instance is running by visiting the following URLS:\n    * Source Cockroach UI - http://localhost:8080\n    * Destination Cockroach UI - http://localhost:8081\n1) Start the `consumer` Spring Boot application.  The `consumer` application will read from Kafka and populate the `destination` database once the `producer` begins generating data.\n    ```\n    ./mvnw -pl consumer -am spring-boot:run\n    ```\n1) Start the `producer` Spring Boot application.  This will slowly load data into the `source` database where the `CHANGEFEED` is enabled.  Once data is written to the `source` database the `CHANGEFEED` will publish data to Kafka and be read by the `consumer` application.\n    ```\n    ./mvnw -pl producer -am spring-boot:run\n    ```\n1) When you are done, you can stop all services with `down.sh`.  To do a full system prune run `prune.sh`.\n\n## Helpful Commands\n\nUse this to show running jobs in `roach-source` cluster\n```bash\ndocker-compose exec roach-source /cockroach/cockroach sql --insecure --execute=\"SHOW JOBS;\"\n```\n\nUse this to see data in Kafka topic\n```bash\ndocker-compose exec kafka /usr/bin/kafka-console-consumer --bootstrap-server=localhost:9092 --from-beginning --topic=source_table\n```\n\nUse this to view data in the `soucre` database\n```bash\ndocker-compose exec roach-source /cockroach/cockroach sql --insecure --database source --execute=\"select count(*) from source_table;\"\n```\n\nUse this to verify data has been loaded into the `destination` database \n```bash\ndocker-compose exec roach-destination /cockroach/cockroach sql --insecure --database destination --execute=\"select count(*) from destination_table;\"\n```\n\nList all Kafka topics\n```bash\ndocker-compose exec kafka /usr/bin/kafka-topics --list --zookeeper zookeeper:2181\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcockroachlabs-field%2Fcdc-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcockroachlabs-field%2Fcdc-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcockroachlabs-field%2Fcdc-example/lists"}