Wso2Dss Box_Carring not working in WSO2esb4.8.0

后端 未结 2 1661
臣服心动
臣服心动 2021-01-23 01:17

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

2条回答
  •  醉话见心
    2021-01-23 02:04

    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(?,?)
                
                
            
            
                
                    
                    
                
            
            
                
                    
                    
                
            
        
    

提交回复
热议问题