Refine CDCSample.
@@ -7,33 +7,20 @@ Pre-requesites:
1) Ensure that MySQL is installed on your computer.
2) Add mysql jdbc driver into {WSO2_SP_HOME}/lib.
2.1)Download JDBC driver (https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.45.tar.gz)
- 3) Add cdc-io-extention into {WSO2_SP_HOME}/lib if you don't already have.
- 4) Set MySQL binary logging to ROW.
- 4.1) Goto [mysqld] section of edit my.cnf file.
- 4.2) Set following settings
- log_error = /var/log/mysql/error.log
- server-id = 1
- log_bin = /var/log/mysql/mysql-bin.log
- expire_logs_days = 10
- max_binlog_size = 100M
- 4.3) Restart the mysql service.
- >> service mysql restart
- 5) Run following. You might want to execute as sudo.
- >> service mysql stop
- >> mkdir /var/log/mysql
- >> chown -R mysql:mysql /var/log/mysql
- >> service mysql start
- 6) Set state.persistence enabled=true in deployment.yaml file.
- 7) Create a database "production".
+ 3) Configure MySQL to enable binary logging.
+ 4.1)Follow https://debezium.io/docs/connectors/mysql/#enabling-the-binlog
+ 4) Enable state persistence in siddhi apps.
+ 5.1)Change state.persistence enabled=true in deployment.yaml file.
+ 5) Create a database "production".
>> CREATE SCHEMA production;
- 8) Make sure to have a user with SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT privileges.
+ 6) Make sure to have a user with SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT privileges.
you can create a user with following.
>> GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'wso2sp' IDENTIFIED BY 'wso2';
- 9) Change the database.
+ 7) Change the database.
>> use production;
- 10) Create table "SweetProductionTable".
+ 8) Create table "SweetProductionTable".
>> CREATE TABLE SweetProductionTable (name VARCHAR(20),amount double(10,2));
- 11) Save this sample.
+ 9) Save this sample.
Executing the Sample:
1) Start the Siddhi application by clicking on 'Run'.
@@ -43,10 +30,10 @@ Note:
If you want to edit this application while it's running, stop the application, make your edits and save the application, and then start it again.
Testing the Sample:
- Use MySQL console or Workbench to insert data to the created table.
+ Insert data to the created table.
>> insert into SweetProductionTable values('chocolate',100.0);
Observe the inserted data is logged on the console.
- CDCSample : outstm : Event{timestamp=1541486685789, data=[chocolate, 100.0], isExpired=false}
+ CDCSample : logStream : Event{timestamp=1541486685789, data=[chocolate, 100.0], isExpired=false}
Optional: Test for operation = 'update' and operation = 'delete' also.
Note: delete operation events will include keys: before_name, before_amount.
