XA 资源变得不可用 XID 引发 -7
XA resource has become unavailable XID raised -7
我以随机方式低于错误。它最初不会抛出错误,但一段时间后会抛出错误。一旦我重新启动我的服务器,一切都会重置并且不会抛出错误。
XA 资源 'XXXXAtomikosDataSource': XID '31302E3137382E36382E3235302E746D30303031353030303138:31302E3137382E36382E3235302E746D3135' 的恢复 -7: XA 资源已变得不可用[=12]
我正在使用以下依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>
并使用配置 bean
@Bean(name= "userTransaction")
public UserTransaction userTransaction() throws Throwable {
UserTransactionImp userTransactionImp = new UserTransactionImp();
return userTransactionImp;
}
@Bean
@Primary
public TransactionManager atomTransactionManager() throws Throwable {
UserTransactionManager userTransactionManager = new UserTransactionManager();
userTransactionManager.setForceShutdown(false);
return userTransactionManager;
}
@Bean("atomikosTransactionManager")
public PlatformTransactionManager platformTransactionManager() throws Throwable {
UserTransaction userTransaction = userTransaction();
TransactionManager transactionManager = atomTransactionManager();
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, transactionManager);
jtaTransactionManager.setAllowCustomIsolationLevels(true);
jtaTransactionManager.setDefaultTimeout(1000);
return jtaTransactionManager;
}
@Bean(name = "atomikosDataSources")
public Map<String, DataSource> atomikosDataSources(PropertiesFactoryBean databaseProperties, Environment environment, BcusDefaultEncrytor bcusDefaultEncrytor) throws SQLException, IOException {
List<String> databases= Collections.list(databaseProperties.getObject().propertyNames()).stream().map(key->key.toString()).filter(key-> key.contains("url")).collect(Collectors.toList());
Map<String, DataSource> collect = databases.stream().collect(Collectors.toMap(dbName -> dbName.split("\.")[0].toUpperCase() + "AtomikosDataSource", dbName -> {
OracleXADataSource dataSource = null;
try {
dataSource = new OracleXADataSource();
dataSource.setURL(environment.getProperty(dbName));
dataSource.setUser(environment.getProperty("database.username"));
dataSource.setPassword(bcusDefaultEncrytor.decryptQAPassword(environment.getProperty("database.password")));
}
catch (SQLException e)
{
LOG.error(
"DatabaseConditionException [errorCode= Error while configuring atomikos data sources- Could not OracleXADataSource object, errorMessage= {} ]",
e.getMessage());
}
catch (Exception e) {
LOG.error(
"DatabaseConditionException [errorCode= Error while configuring atomikos data sources- Could not decrypt QA Password make sure you have proper **QA** Encryption password in your folder, errorMessage= {} ]",
e.getMessage());
}
AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
xaDataSource.setXaDataSource(dataSource);
xaDataSource.setUniqueResourceName(dbName.split("\.")[0].toUpperCase() + "AtomikosDataSource");
xaDataSource.setPoolSize(5);
return xaDataSource;
}));
return collect;
}
问题是由于 spring-boot-starter-jta-atomikos brings:1.4.2.RELEASE.
中的 atomikos 3.9.3 版本存在错误
将版本更新到 atomikos 4.0.4 后,问题就解决了。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
<exclusions>
<exclusion>
<artifactId>transactions-jdbc</artifactId>
<groupId>com.atomikos</groupId>
</exclusion>
<exclusion>
<artifactId>transactions-jms</artifactId>
<groupId>com.atomikos</groupId>
</exclusion>
<exclusion>
<artifactId>transactions-jta</artifactId>
<groupId>com.atomikos</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jms</artifactId>
<version>${transaction.version}</version>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jta</artifactId>
<version>${transaction.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.0.1B_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jdbc</artifactId>
<version>${transaction.version}</version>
</dependency>
我以随机方式低于错误。它最初不会抛出错误,但一段时间后会抛出错误。一旦我重新启动我的服务器,一切都会重置并且不会抛出错误。
XA 资源 'XXXXAtomikosDataSource': XID '31302E3137382E36382E3235302E746D30303031353030303138:31302E3137382E36382E3235302E746D3135' 的恢复 -7: XA 资源已变得不可用[=12]
我正在使用以下依赖项。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>
并使用配置 bean
@Bean(name= "userTransaction")
public UserTransaction userTransaction() throws Throwable {
UserTransactionImp userTransactionImp = new UserTransactionImp();
return userTransactionImp;
}
@Bean
@Primary
public TransactionManager atomTransactionManager() throws Throwable {
UserTransactionManager userTransactionManager = new UserTransactionManager();
userTransactionManager.setForceShutdown(false);
return userTransactionManager;
}
@Bean("atomikosTransactionManager")
public PlatformTransactionManager platformTransactionManager() throws Throwable {
UserTransaction userTransaction = userTransaction();
TransactionManager transactionManager = atomTransactionManager();
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, transactionManager);
jtaTransactionManager.setAllowCustomIsolationLevels(true);
jtaTransactionManager.setDefaultTimeout(1000);
return jtaTransactionManager;
}
@Bean(name = "atomikosDataSources")
public Map<String, DataSource> atomikosDataSources(PropertiesFactoryBean databaseProperties, Environment environment, BcusDefaultEncrytor bcusDefaultEncrytor) throws SQLException, IOException {
List<String> databases= Collections.list(databaseProperties.getObject().propertyNames()).stream().map(key->key.toString()).filter(key-> key.contains("url")).collect(Collectors.toList());
Map<String, DataSource> collect = databases.stream().collect(Collectors.toMap(dbName -> dbName.split("\.")[0].toUpperCase() + "AtomikosDataSource", dbName -> {
OracleXADataSource dataSource = null;
try {
dataSource = new OracleXADataSource();
dataSource.setURL(environment.getProperty(dbName));
dataSource.setUser(environment.getProperty("database.username"));
dataSource.setPassword(bcusDefaultEncrytor.decryptQAPassword(environment.getProperty("database.password")));
}
catch (SQLException e)
{
LOG.error(
"DatabaseConditionException [errorCode= Error while configuring atomikos data sources- Could not OracleXADataSource object, errorMessage= {} ]",
e.getMessage());
}
catch (Exception e) {
LOG.error(
"DatabaseConditionException [errorCode= Error while configuring atomikos data sources- Could not decrypt QA Password make sure you have proper **QA** Encryption password in your folder, errorMessage= {} ]",
e.getMessage());
}
AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
xaDataSource.setXaDataSource(dataSource);
xaDataSource.setUniqueResourceName(dbName.split("\.")[0].toUpperCase() + "AtomikosDataSource");
xaDataSource.setPoolSize(5);
return xaDataSource;
}));
return collect;
}
问题是由于 spring-boot-starter-jta-atomikos brings:1.4.2.RELEASE.
中的 atomikos 3.9.3 版本存在错误将版本更新到 atomikos 4.0.4 后,问题就解决了。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
<exclusions>
<exclusion>
<artifactId>transactions-jdbc</artifactId>
<groupId>com.atomikos</groupId>
</exclusion>
<exclusion>
<artifactId>transactions-jms</artifactId>
<groupId>com.atomikos</groupId>
</exclusion>
<exclusion>
<artifactId>transactions-jta</artifactId>
<groupId>com.atomikos</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jms</artifactId>
<version>${transaction.version}</version>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jta</artifactId>
<version>${transaction.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.0.1B_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jdbc</artifactId>
<version>${transaction.version}</version>
</dependency>