{"id":28829277,"url":"https://github.com/ballerina-platform/module-ballerinax-cdc","last_synced_at":"2026-02-18T08:07:39.508Z","repository":{"id":291704757,"uuid":"978501119","full_name":"ballerina-platform/module-ballerinax-cdc","owner":"ballerina-platform","description":"The Ballerina CDC module is part of the Ballerina Extended Library. It provides a spec-compliant, production-grade  listener designed to stream real-time database changes.","archived":false,"fork":false,"pushed_at":"2026-02-10T05:14:40.000Z","size":247,"stargazers_count":2,"open_issues_count":1,"forks_count":4,"subscribers_count":46,"default_branch":"main","last_synced_at":"2026-02-10T10:40:20.292Z","etag":null,"topics":["ballerina","cdc","change-data-capture","database","event-driven","integration","realtime","wso2"],"latest_commit_sha":null,"homepage":null,"language":"Ballerina","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ballerina-platform.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-06T04:52:06.000Z","updated_at":"2026-02-10T05:14:45.000Z","dependencies_parsed_at":"2025-05-26T02:49:24.122Z","dependency_job_id":null,"html_url":"https://github.com/ballerina-platform/module-ballerinax-cdc","commit_stats":null,"previous_names":["ballerina-platform/module-ballerinax-cdc"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ballerina-platform/module-ballerinax-cdc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerinax-cdc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerinax-cdc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerinax-cdc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerinax-cdc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ballerina-platform","download_url":"https://codeload.github.com/ballerina-platform/module-ballerinax-cdc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ballerina-platform%2Fmodule-ballerinax-cdc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29573497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T07:57:19.261Z","status":"ssl_error","status_checked_at":"2026-02-18T07:57:18.820Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ballerina","cdc","change-data-capture","database","event-driven","integration","realtime","wso2"],"created_at":"2025-06-19T05:12:42.081Z","updated_at":"2026-02-18T08:07:39.488Z","avatar_url":"https://github.com/ballerina-platform.png","language":"Ballerina","funding_links":[],"categories":[],"sub_categories":[],"readme":"Ballerina CDC Connector\n===================\n\n  [![Build](https://github.com/ballerina-platform/module-ballerinax-cdc/actions/workflows/build-timestamped-master.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-cdc/actions/workflows/build-timestamped-master.yml)\n  [![Trivy](https://github.com/ballerina-platform/module-ballerinax-cdc/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-cdc/actions/workflows/trivy-scan.yml)\n  [![codecov](https://codecov.io/gh/ballerina-platform/module-ballerinax-cdc/branch/main/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerinax-cdc)\n  [![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-cdc/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-cdc/actions/workflows/build-with-bal-test-graalvm.yml)\n  [![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-cdc.svg)](https://github.com/ballerina-platform/module-ballerinax-cdc/commits/main)\n  [![GitHub Issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-library/module/cdc.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-library/labels/module%2Fcdc)\n\nThe Ballerina Change Data Capture (CDC) module provides APIs to capture and process database change events in real-time. This module enables developers to define services that handle change capture events such as inserts, updates, and deletes. It is built on top of the Debezium framework and supports popular databases like MySQL and Microsoft SQL Server.\n\nWith the CDC module, you can:\n- Capture real-time changes from databases.\n- Process and react to database events programmatically.\n- Build event-driven applications with ease.\n\n## Quickstart\n\n### Step 1: Import Required Modules\n\nAdd the following imports to your Ballerina program:\n\n- `ballerinax/cdc`: Core module that provides APIs to capture and process database change events.\n- `ballerinax/mysql`: Provides MySQL-specific listener and types for CDC. Replace with the corresponding module for your database if needed.\n- `ballerinax/mysql.cdc.driver as _`: Debezium-based driver for MySQL CDC. Use the appropriate driver for your database (e.g., `mssql.cdc.driver`, `postgresql.cdc.driver`, or `oracledb.cdc.driver`).\n\n```ballerina\nimport ballerinax/cdc;\nimport ballerinax/mysql;\nimport ballerinax/mysql.cdc.driver as _;\n```\n\n### Step 2: Configure the CDC Listener\n\nCreate a CDC listener for your MySQL database by specifying the connection details:\n\n```ballerina\nlistener mysql:CdcListener mysqlListener = new ({\n    database: {\n        hostname: \"localhost\",\n        port: 3306,\n        username: \"username\",\n        password: \"password\",\n        includedDatabases: [\"inventory\"]\n    }\n});\n```\n\n### Step 3: Define the CDC Service\n\nImplement a `cdc:Service` to handle database change events:\n\n```ballerina\nservice on mysqlListener {\n\n    remote function onRead(record {} after) returns cdc:Error? {\n        // Handle the read event\n        log:printInfo(`Record read: ${after}`);\n    }\n\n    remote function onCreate(record {} after) returns cdc:Error? {\n        // Handle the create event\n        log:printInfo(`Record created: ${after}`);\n    }\n\n    remote function onUpdate(record {} before, record {} after) returns cdc:Error? {\n        // Handle the update event\n        log:printInfo(`Record updated from: ${before}, to ${after}`);\n    }\n\n    remote function onDelete(record {} before) returns cdc:Error? {\n        // Handle the delete event\n        log:printInfo(`Record deleted: ${before}`);\n    }\n}\n```\n\n### Step 4: Run the Application\n\nRun your Ballerina application:\n\n```bash\nbal run\n```\n\n## Examples\n\nThe `cdc` module provides practical examples illustrating its usage in various real-world scenarios. Explore these [examples](https://github.com/ballerina-platform/module-ballerinax-cdc/tree/main/examples) to understand how to capture and process database change events effectively.\n\n1. [Fraud Detection](https://github.com/ballerina-platform/module-ballerinax-cdc/tree/main/examples/fraud-detection) - Detect suspicious transactions in a financial database and send fraud alerts via email. This example showcases how to integrate the CDC module with the Gmail connector to notify stakeholders of potential fraud.\n\n2. [Cache Management](https://github.com/ballerina-platform/module-ballerinax-cdc/tree/main/examples/cache-management) - Synchronize a Redis cache with changes in a MySQL database. It listens to changes in the `products`, `vendors`, and `product_reviews` tables and updates the Redis cache accordingly.\n\n## Issues and projects\n\nThe **Issues** and **Projects** tabs are disabled for this repository as this is part of the Ballerina library. To report bugs, request new features, start new discussions, view project boards, etc., visit the Ballerina library [parent repository](https://github.com/ballerina-platform/ballerina-library).\n\nThis repository only contains the source code for the package.\n\n## Build from the source\n\n### Prerequisites\n\n1. Download and install Java SE Development Kit (JDK) version 21. You can download it from either of the following sources:\n\n   * [Oracle JDK](https://www.oracle.com/java/technologies/downloads/)\n   * [OpenJDK](https://adoptium.net/)\n\n    \u003e **Note:** After installation, remember to set the `JAVA_HOME` environment variable to the directory where JDK was installed.\n\n2. Download and install [Docker](https://www.docker.com/get-started).\n\n    \u003e **Note**: Ensure that the Docker daemon is running before executing any tests.\n\n3. Export your GitHub personal access token with read package permissions as follows.\n        \n        export packageUser=\u003cUsername\u003e\n        export packagePAT=\u003cPersonal access token\u003e\n\n### Build options\n\nExecute the commands below to build from the source.\n\n1. To build the package:\n\n   ```bash\n   ./gradlew clean build\n   ```\n\n2. To run the tests:\n\n   ```bash\n   ./gradlew clean test\n   ```\n\n3. To build the without the tests:\n\n   ```bash\n   ./gradlew clean build -x test\n   ```\n\n4. To debug package with a remote debugger:\n\n   ```bash\n   ./gradlew clean build -Pdebug=\u003cport\u003e\n   ```\n\n5. To debug with the Ballerina language:\n\n   ```bash\n   ./gradlew clean build -PbalJavaDebug=\u003cport\u003e\n   ```\n\n6. Publish the generated artifacts to the local Ballerina Central repository:\n\n    ```bash\n    ./gradlew clean build -PpublishToLocalCentral=true\n    ```\n\n7. Publish the generated artifacts to the Ballerina Central repository:\n\n   ```bash\n   ./gradlew clean build -PpublishToCentral=true\n   ```\n\n## Contribute to Ballerina\n\nAs an open-source project, Ballerina welcomes contributions from the community.\n\nFor more information, go to the [contribution guidelines](https://github.com/ballerina-platform/ballerina-lang/blob/master/CONTRIBUTING.md).\n\n## Code of conduct\n\nAll the contributors are encouraged to read the [Ballerina Code of Conduct](https://ballerina.io/code-of-conduct).\n\n## Useful links\n\n* For more information go to the [`cdc` package](https://lib.ballerina.io/ballerinax/cdc/latest).\n* For example demonstrations of the usage, go to [Ballerina By Examples](https://ballerina.io/learn/by-example/).\n* Chat live with us via our [Discord server](https://discord.gg/ballerinalang).\n* Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fballerina-platform%2Fmodule-ballerinax-cdc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fballerina-platform%2Fmodule-ballerinax-cdc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fballerina-platform%2Fmodule-ballerinax-cdc/lists"}