Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多数据源,全局事务无效,是否需要其他配置 #12

Closed
momolela opened this issue Oct 13, 2020 · 4 comments
Closed

多数据源,全局事务无效,是否需要其他配置 #12

momolela opened this issue Oct 13, 2020 · 4 comments

Comments

@momolela
Copy link
Contributor

多数据源,全局事务无效,是否需要其他配置

数据源配置
image

程序启动的时候,还有这样的打印
image

程序测试事务,在controller类中调用下面方法
image

当/0报错没有回滚

@louislivi 请问是否需要其他配置?

@momolela
Copy link
Contributor Author

启动时候的打印
2020-10-13 10:06:52.408 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?
2020-10-13 10:06:52.408 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?
2020-10-13 10:06:52.410 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?
2020-10-13 10:06:52.412 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?
2020-10-13 10:06:52.412 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?
2020-10-13 10:06:52.412 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?
2020-10-13 10:06:52.414 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?
2020-10-13 10:06:52.417 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?
2020-10-13 10:06:52.418 WARN 16008 --- [ main] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for oracle.jdbc.driver.T4CConnection@148fca83: WARNING: transaction manager not running?

@momolela
Copy link
Contributor Author

测试方法
@transactional
public void transactionTest(String num) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
Map<String, Object> insertParam1 = new HashMap<>();
insertParam1.put("INMSG", "10000");
insertParam1.put("OUTMSG", "10000");
insertParam1.put("SUCMSG", "10000");
insertParam1.put("ERRMSG", "10000");
insertParam1.put("DATETIME", LocalDate.parse("2020-10-12", formatter).format(formatter));
haiLogMapper.insertMsgCount(insertParam1);
int haha = 1 / Integer.parseInt(num);
Map<String, Object> insertParam2 = new HashMap<>();
insertParam2.put("INMSG", "20000");
insertParam2.put("OUTMSG", "20000");
insertParam2.put("SUCMSG", "20000");
insertParam2.put("ERRMSG", "20000");
insertParam2.put("DATETIME", LocalDate.parse("2020-10-12", formatter).format(formatter));
haiLogMapper.insertMsgCount(insertParam2);
}

@momolela
Copy link
Contributor Author

`# fastdep 支持多数据源
fastdep:
datasource:
base:
mapper: hai.mcentre.mapper.base
driver-class-name: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@127.0.0:1521/orcl
username: xxx
password: xxx
initialSize: 10
minIdle: 5
maxActive: 100
maxWait: 10000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
removeAbandoned: true
removeAbandonedTimeout: 180
keepAlive: true
log:
mapper: hai.mcentre.mapper.log
driver-class-name: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@127.0.0.1:1521/orcl
username: xxx
password: xxx
initialSize: 10
minIdle: 5
maxActive: 100
maxWait: 10000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
removeAbandoned: true
removeAbandonedTimeout: 180
keepAlive: true

mybatis

mybatis:
mapper-locations: classpath:mybatis/mapper/*.xml
config-location: classpath:mybatis/mybatis-config.xml`

@louislivi
Copy link
Owner

你可以将fastdep-test基础的改为你的数据源信息进行测试,先排查是否是你设置了事物bean或者注入了一些额外的事物数据源相关bean,导致全局事物失效。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants