重要修复,关于因为分布式事务与druid兼容性问题导致数据库超时的bug修复

This commit is contained in:
dftre 2024-09-11 16:50:00 +08:00
parent a2954029fb
commit 0536ca3a4b

View File

@ -37,14 +37,10 @@ public class DynamicDataSourceProperties implements InitializingBean {
dataSource.setConnectProperties(prop); dataSource.setConnectProperties(prop);
AtomikosDataSourceBean ds = new AtomikosDataSourceBean(); AtomikosDataSourceBean ds = new AtomikosDataSourceBean();
ds.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource"); ds.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
// 添加连接池限制
ds.setMaxPoolSize(10);
ds.setMinPoolSize(3);
ds.setBorrowConnectionTimeout(60);
ds.setUniqueResourceName(name); ds.setUniqueResourceName(name);
ds.setXaProperties(prop); ds.setXaProperties(prop);
setProperties(dataSource, prop);
ds.setXaDataSource(dataSource); ds.setXaDataSource(dataSource);
setProperties(dataSource, prop);
return ds; return ds;
} }
@ -72,37 +68,38 @@ public class DynamicDataSourceProperties implements InitializingBean {
dataSource.setUrl(prop.getProperty("url")); dataSource.setUrl(prop.getProperty("url"));
dataSource.setUsername(prop.getProperty("username")); dataSource.setUsername(prop.getProperty("username"));
dataSource.setPassword(prop.getProperty("password")); dataSource.setPassword(prop.getProperty("password"));
if(prop.getProperty("initialSize") != null){ if (prop.getProperty("initialSize") != null) {
dataSource.setInitialSize(Integer.parseInt(prop.getProperty("initialSize"))); dataSource.setInitialSize(Integer.parseInt(prop.getProperty("initialSize")));
} }
if(prop.getProperty("minIdle") != null){ if (prop.getProperty("minIdle") != null) {
dataSource.setMinIdle(Integer.parseInt(prop.getProperty("minIdle"))); dataSource.setMinIdle(Integer.parseInt(prop.getProperty("minIdle")));
} }
if(prop.getProperty("maxActive") != null){ if (prop.getProperty("maxActive") != null) {
dataSource.setMaxActive(Integer.parseInt(prop.getProperty("maxActive"))); dataSource.setMaxActive(Integer.parseInt(prop.getProperty("maxActive")));
} }
if(prop.getProperty("maxWait") != null){ if (prop.getProperty("maxWait") != null) {
dataSource.setMaxWait(Long.parseLong(prop.getProperty("maxWait"))); dataSource.setMaxWait(Long.parseLong(prop.getProperty("maxWait")));
} }
if(prop.getProperty("timeBetweenEvictionRunsMillis") != null){ if (prop.getProperty("timeBetweenEvictionRunsMillis") != null) {
dataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(prop.getProperty("timeBetweenEvictionRunsMillis"))); dataSource.setTimeBetweenEvictionRunsMillis(
Long.parseLong(prop.getProperty("timeBetweenEvictionRunsMillis")));
} }
if(prop.getProperty("minEvictableIdleTimeMillis") != null){ if (prop.getProperty("minEvictableIdleTimeMillis") != null) {
dataSource.setMinEvictableIdleTimeMillis(Long.parseLong(prop.getProperty("minEvictableIdleTimeMillis"))); dataSource.setMinEvictableIdleTimeMillis(Long.parseLong(prop.getProperty("minEvictableIdleTimeMillis")));
} }
if(prop.getProperty("maxEvictableIdleTimeMillis") != null){ if (prop.getProperty("maxEvictableIdleTimeMillis") != null) {
dataSource.setMaxEvictableIdleTimeMillis(Long.parseLong(prop.getProperty("maxEvictableIdleTimeMillis"))); dataSource.setMaxEvictableIdleTimeMillis(Long.parseLong(prop.getProperty("maxEvictableIdleTimeMillis")));
} }
if(prop.getProperty("validationQuery") != null){ if (prop.getProperty("validationQuery") != null) {
dataSource.setValidationQuery(prop.getProperty("validationQuery")); dataSource.setValidationQuery(prop.getProperty("validationQuery"));
} }
if(prop.getProperty("testWhileIdle") != null){ if (prop.getProperty("testWhileIdle") != null) {
dataSource.setTestWhileIdle(Boolean.parseBoolean(prop.getProperty("testWhileIdle"))); dataSource.setTestWhileIdle(Boolean.parseBoolean(prop.getProperty("testWhileIdle")));
} }
if(prop.getProperty("testOnBorrow") != null){ if (prop.getProperty("testOnBorrow") != null) {
dataSource.setTestOnBorrow(Boolean.parseBoolean(prop.getProperty("testOnBorrow"))); dataSource.setTestOnBorrow(Boolean.parseBoolean(prop.getProperty("testOnBorrow")));
} }
if(prop.getProperty("testOnReturn") != null){ if (prop.getProperty("testOnReturn") != null) {
dataSource.setTestOnReturn(Boolean.parseBoolean(prop.getProperty("testOnReturn"))); dataSource.setTestOnReturn(Boolean.parseBoolean(prop.getProperty("testOnReturn")));
} }
} }