[英]Exception thrown when using non-XA datasource in two-phase commit transaction
我的Websphere应用程序有3个数据源。 其中两个是XA,另一个是非XA。
我通过使用@transactional注释对方法进行注释来使Java方法具有事务性。
在该方法中,执行了3个任务。 第一个使用一个XA数据源进行一些更新,然后第二个使用非XA数据源选择一些记录,最后一个任务使用另一个XA数据源再次进行一些更新。
但是,会引发异常,并出现以下错误: An illegal attempt to commit a one phase capable resource with existing two phase capable resources
我想知道为什么即使我的应用程序仅使用非XA来选择一些数据并且不需要提交,还是会发生上述错误,如果不允许我将非XA数据源更改为XA,如何解决该问题? 。
默认情况下,非XA资源无法参与分布式事务。 因此,您有以下选择:
Select Resources > JDBC > Data sources Select the name of the data source that you want to configure. Select WebSphere Application Server data source properties from the Additional Properties heading. Select Non-transactional data source. Click OK.
当开始第二个任务时,在使用@Transaction
注释时, need to be commit or rolled back
在XA数据源上更新的前一个任务,整个任务会自动执行一次事务,因此请不要使用@Transaction注释,而应使用@Transaction注释将每个任务放在单独的事务中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.