The siddhi-io-cdc extension is an extension to Siddhi that captures change data from databases such as MySQL, MS SQL, PostgreSQL, H2 and Oracle.
For information on Siddhi and it's features refer Siddhi Documentation.
- Versions 3.x and above with group id
io.siddhi.extension.*
from here. - Versions 2.x and lower with group id
org.wso2.extension.siddhi.*
from here.
Latest API Docs is 2.0.8.
- cdc (Source)
The CDC source receives events when change events (i.e., INSERT, UPDATE, DELETE) are triggered for a database table. Events are received in the 'key-value' format.
There are two modes you could perform CDC: Listening mode and Polling mode.
In polling mode, the datasource is periodically polled for capturing the changes. The polling period can be configured.
In polling mode, you can only capture INSERT and UPDATE changes.
On listening mode, the Source will keep listening to the Change Log of the database and notify in case a change has taken place. Here, you are immediately notified about the change, compared to polling mode.
The key values of the map of a CDC change event are as follows.
For 'listening' mode:
For insert: Keys are specified as columns of the table.
For delete: Keys are followed by the specified table columns. This is achieved via 'before_'. e.g., specifying 'before_X' results in the key being added before the column named 'X'.
For update: Keys are followed followed by the specified table columns. This is achieved via 'before_'. e.g., specifying 'before_X' results in the key being added before the column named 'X'.
For 'polling' mode: Keys are specified as the columns of the table.#### Preparations required for working with Oracle Databases in listening mode
Using the extension in Windows, Mac OSX and AIX are pretty straight forward inorder to achieve the required behaviour please follow the steps given below
- Download the compatible version of oracle instantclient for the database version from here and extract
- Extract and set the environment variableLD_LIBRARY_PATH
to the location of instantclient which was exstracted as shown below
export LD_LIBRARY_PATH=<path to the instant client location>
- Inside the instantclient folder which was download there are two jarsxstreams.jar
andojdbc<version>.jar
convert them to OSGi bundles using the tools which were provided in the<distribution>/bin
for converting theojdbc.jar
use the toolspi-provider.sh|bat
and for the conversion ofxstreams.jar
use the jni-provider.sh as shown below(Note: this way of converting Xstreams jar is applicable only for Linux environments for other OSs this step is not required and converting it through thejartobundle.sh
tool is enough)
./jni-provider.sh <input-jar> <destination> <comma seperated native library names>
once ojdbc and xstreams jars are converted to OSGi copy the generated jars to the<distribution>/lib
. Currently siddhi-io-cdc only supports the oracle database distributions 12 and above
See parameter: mode for supported databases and change events.
JDBC connector jar should be added to the runtime. Download the JDBC connector jar based on the database type that is being used.
For MySQL, use connector version 5.1.xx.
In addition to that, there are some prerequisites that need to be met based on the CDC mode used. Please find them below.
Default mode (Listening mode):
Currently MySQL, PostgreSQL and SQLServer are supported in Listening Mode. To capture the change events, databases have to be configured as shown below.
- MySQL - https://debezium.io/documentation/reference/connectors/mysql.html#setup-the-mysql-server
- PostgreSQL - https://debezium.io/docs/connectors/postgresql/#setting-up-PostgreSQL
- SQLServer - https://debezium.io/docs/connectors/sqlserver/#setting-up-sqlserver
Polling mode:
- Change data capturing table should be have a polling column. Auto Incremental column or Timestamp can be used.
Please see API docs for more details about change data capturing modes.
For installing this extension on various siddhi execution environments refer Siddhi documentation section on adding extensions.
The CDC functionality are tested with the docker base integration test framework. The test framework initialize a docker container with required configuration before execute the test suit.
Start integration tests
-
Install and run docker
-
To run the integration tests, navigate to the siddhi-io-cdc/ directory and issue the following commands.
-
H2 default:
mvn clean install
-
MySQL 5.7:
mvn verify -P local-mysql -Dskip.surefire.test=true
-
Postgres 9.6:
mvn verify -P local-postgres -Dskip.surefire.test=true
-
MSSQL:
mvn verify -P local-mssql -Dskip.surefire.test=true
-
Oracle 11.2.0.2-xe:
mvn verify -P local-oracle -Dskip.surefire.test=true
-
-
We encourage users to ask questions and get support via StackOverflow, make sure to add the
siddhi
tag to the issue for better response. -
If you find any issues related to the extension please report them on the issue tracker.
-
For production support and other contribution related information refer Siddhi Community documentation.