Home > Back-end >  Seata manual configuration data sources, could you tell me if need to roll back how to configure
Seata manual configuration data sources, could you tell me if need to roll back how to configure

Time:01-14

Manually configure the data source, data useless seata agent, error code to run after the seata seaver side has log print
 
The Rollback global transaction successfully, xid=82.156.78.45:8700-2001069320.


The following is a data source configuration
 
Public class MybatisConfig {

Protected Logger Logger=LoggerFactory. GetLogger (getClass ());


@ Bean
@ ConfigurationProperties (" spring datasource. The druid. Master ")
Public DataSource masterDataSource (DruidProperties DruidProperties) {
DruidDataSource dataSource=DruidDataSourceBuilder. The create (). The build ();
Return druidProperties. The dataSource (dataSource);
}

@ Bean
@ Primary
@ DependsOn (" masterDataSource ")
Public DynamicDataSource dataSource (dataSource masterDataSource) {
Map TargetDataSources=new HashMap<> (a);
TargetDataSources. Put (DataSourceType. MASTER. The name (), masterDataSource);
SetDataSource (targetDataSources, DataSourceType. SLAVE. The name (), "slaveDataSource");
Return new DynamicDataSource (masterDataSource targetDataSources);
}

/* *
* set up the data source
*
* @ param targetDataSources alternative data collection
* @ param sourceName data source name
* @ param beanName bean name
*/
Public void setDataSource (Map TargetDataSources, String sourceName, String beanName) {
Try {
The DataSource DataSource=SpringUtils. GetBean (beanName);
TargetDataSources. Put (sourceName, dataSource);
} the catch (Exception e) {
Logger. The error (" failed to find alternative sources ");
}
}
}

But it didn't happen to rollback, and the things not to join the database
  • Related