I am working with wso2dss3.0.1 and wso2esb4.8.0.I wish to work with Transactions for that i enabled box_carying in wso2dss and its working fine.Means i wish insert the data into
There is a workaround, use request_box to wrap multiple sql non-query operation in a single request to avoid using session. If any sql in the request fails, the whole request will be rollback.
First you need a mysql database named MyDB with a user named root whose password is root and a Postgresql database also named MyDB with a user named postgres whose password is root. Then create a table named customer in both databases:
CREATE TABLE customer (
cust_id int(11) NOT NULL,
name varchar(255) NOT NULL,
PRIMARY KEY (`cust_id`)
);
The sample inserts a record into mysql, then inserts two records with the same cust_id into postgres which causes an error, so the whole transaction will be rolled back and you will not see the record inserted into mysql.
Below is my proxy service definition:
$1
$2
$1
$2
$1
$2
My data service is defined as below:
org.postgresql.xa.PGXADataSource
localhost
5432
MyDB
postgres
root
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
jdbc:mysql://localhost:3306/MyDB
root
root
INSERT INTO customer VALUES(?,?)
INSERT INTO customer VALUES(?,?)