1

我有一个独立的应用程序 A,它调用部署在 jboss eap 6.2.3 中的 web 服务 B。jboss 中的应用程序使用 mysql 数据源。此应用程序集成运行良好。

我需要将独立应用程序本身 web 化为 spring rest 数据 jpa 微服务所以我为该独立应用程序 A 编写了一个 spring boot 包装器。它在嵌入式 tomcat 中运行并调用在 jboss 中运行的应用程序 B。我还将一些配置逻辑从属性文件移植到嵌入式 h2 数据库中。

现在在一些地方,我看到下面显示的这个异常,由 jboss 中的应用程序 B 插入到 mysql 中。我的猜测是之前的简单事务,现在运行良好已经变成了有时会失败的 2 阶段提交。如何防止这种情况?

Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
    at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177)
    at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)
    at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
    at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:92) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
    ... 67 more
Caused by: org.infinispan.CacheException: Could not prepare. 
    at org.infinispan.transaction.synchronization.SynchronizationAdapter.beforeCompletion(SynchronizationAdapter.java:70) [infinispan-core-5.2.7.Final-redhat-2.jar:5.2.7.Final-redhat-2]
    at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)
    at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)
    at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)
    at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:162)
    at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)
    ... 70 more
Caused by: javax.transaction.xa.XAException
    at org.infinispan.transaction.TransactionCoordinator.prepare(TransactionCoordinator.java:161) [infinispan-core-5.2.7.Final-redhat-2.jar:5.2.7.Final-redhat-2]
    at org.infinispan.transaction.TransactionCoordinator.prepare(TransactionCoordinator.java:123) [infinispan-core-5.2.7.Final-redhat-2.jar:5.2.7.Final-redhat-2]
    at org.infinispan.transaction.synchronization.SynchronizationAdapter.beforeCompletion(SynchronizationAdapter.java:68) [infinispan-core-5.2.7.Final-redhat-2.jar:5.2.7.Final-redhat-2]
    ... 75 more
4

2 回答 2

2

Spring Boot 对 JTA 提供了开箱即用的支持。当它在 JTA 事务管理器可用的环境中运行时,它会使用它而不是为您的数据存储创建本地事务管理器。如果这不是您想要的,您可以通过添加spring.jta.enabled=false到您的配置来禁用 jta 支持。

于 2015-08-03T07:07:29.197 回答
0

Thanks for the answer.Will be useful in some scenarios. However after posting I realised the flaw in the question.

standalone application A webified application(even if a microservice runninging embeddedtomcat ) say A1

Both are actually just rest clients to rest services running in a webservice B deployed in jboss eap 6.2.3..

A and A1 might as well be replaced by just a simple human visitor visting from a browser the application B.

I dont think A or A1 can influence the transactions in any ways for B. Right?

Anyways the problem was due to the closeness to B of the application A1. The actual problem was related to a cluster event for the cluster in which B was deployed and triggering of it by A1. A bit complicated scenario. The only problem was that the insert was being attempted too soon before the cluster change event could even reach.

于 2015-08-05T11:31:16.147 回答