`

When to configure an XA datasource?

阅读更多
If you ever came across this warning message from JBoss, you might wonder what's wrong:

WARN [TxConnectionManager] Prepare called on a local tx. Use of local transactions on a jta transaction with more than one branch may result in inconsistent data in some cases of failure.

It's relevant to JBoss Transaction Management Service for multiple datasources. That is, you have multiple datasources configured and your transactions span multiple data sources. In this case, you need to configure them as XA datasources so that JBoss would not complain.

This is often the case when using Oracle, as you can have multiple users/schema in one database. My test showed this is when XA datasources should be configured.

For instance, we can have two users "BILLING" and "LOG" in one Oracle database. We need to configure two datasources for each of them. If transactions span across these two users, we need to configure xa-datasources:

<xa-datasource>
		<jndi-name>BILLINGDS_XA</jndi-name>
		<track-connection-by-tx>true</track-connection-by-tx>
		<isSameRM-override-value>false</isSameRM-override-value>
		<managedconnectionfactory-class>org.jboss.resource.adapter.jdbc.xa.oracle.XAOracle ManagedConnectionFactory</managedconnectionfactory-class>
		<transaction-isolation></transaction-isolation>
		<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
		<xa-datasource-property name="URL">jdbc:oracle:thin:@dbserverIP:1521:SID</xa-datasource-property>
		<xa-datasource-property name="User">BILLING</xa-datasource-property>
		<xa-datasource-property name="Password">passwordOfBILLING</xa-datasource-property>
		<min-pool-size>5</min-pool-size>
	  <max-pool-size>10</max-pool-size>
		<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.Oracle ExceptionSorter</exception-sorter-class-name>
		
	  <mbean code="org.jboss.resource.adapter.jdbc.xa.oracle.Or acleXAExceptionFormatter" name="jboss.jca:service=OracleXAExceptionFormatter">
	    <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
  	</mbean>
  </xa-datasource>

<xa-datasource>
		<jndi-name>LOGDS_XA</jndi-name>
		<track-connection-by-tx>true</track-connection-by-tx>
		<isSameRM-override-value>false</isSameRM-override-value>
		<managedconnectionfactory-class>org.jboss.resource.adapter.jdbc.xa.oracle.XAOracle ManagedConnectionFactory</managedconnectionfactory-class>
		<transaction-isolation></transaction-isolation>
		<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
		<xa-datasource-property name="URL">jdbc:oracle:thin:@dbserverIP:1521:SID</xa-datasource-property>
		<xa-datasource-property name="User">LOG</xa-datasource-property>
		<xa-datasource-property name="Password">passwdOfLOG</xa-datasource-property>
		<min-pool-size>5</min-pool-size>
	  <max-pool-size>10</max-pool-size>
		<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.Oracle ExceptionSorter</exception-sorter-class-name>
		
	  <mbean code="org.jboss.resource.adapter.jdbc.xa.oracle.Or acleXAExceptionFormatter" name="jboss.jca:service=OracleXAExceptionFormatter">
	    <depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
  	</mbean>
  </xa-datasource>



Another point is that javax.transaction.UserTransactiion is the JTA api for explicit management of transaction boundaries. This api cannot work properly without JBoss transaction management service turned on. That is, it only works with local-tx-datasource and xa-datasource configurations, not no-tx-datasource. Since it's part of the container's (JBoss for example) Transaction Management Service.
分享到:
评论

相关推荐

    A powerful tool to configure network clientside

    this is a powerful tool to configure network, please download both clientside and serverside.

    Tomcat6.x Configure DataSource

    标题 "Tomcat6.x Configure DataSource" 指的是在Tomcat 6.x版本中配置数据源(DataSource)的过程。在Java应用服务器中,数据源是一个关键组件,它负责管理数据库连接,提供给应用程序使用。配置数据源能提高性能,...

    Configure RTX v5.pdf

    Thread Configuration provides several parameters to configure the Thread Management functions. Timer Configuration provides several parameters to configure the Timer Management functions. Event ...

    How to configure ODBC DSN in Client to access DB2 for Windows.

    This article introduces how to configure ODBC DSN in Client to access remote DB2 for windows in detail. Then I give a sample how to access remote DB2 database with ODBC by DB Query Analyzer ...

    How to configure ODBC DSN to access local DB2 for Windows

    This article introduces how to configure ODBC DSN in Server to access local DB2 for windows in detail. Then I give a sample how to access local DB2 database with ODBC by DB Query Analyzer expediently.

    haxmfori7.rar

    在描述中提到的“Failed to configure driver: unknown error. Failed to open driver”是一个常见的错误提示,意味着在安装或配置HAXM时遇到了问题。 Intel HAXM依赖于计算机的硬件虚拟化功能,尤其是CPU的虚拟化...

    How to configure DCM UDS with the DEXT Editor.pdf

    How to configure DCM UDS with the DEXT Editor.pdf

    How to Configure Odoo 13 on Pycharm Ubuntu 18(1).mp4

    How to Configure Odoo 13 on Pycharm Ubuntu 18 ubuntu18下安装ODOO13 pycharm配置ODOO13开发环境

    Networkers2009:BRKNMS-2004 - 13 Smart Ways To Configure your Cisco IOS Network Elements

    Networkers2009:BRKNMS-2004 - 13 Smart Ways To Configure your Cisco IOS Network Elements

    vim-configure.tar.gz_vim_vim_configure

    "vim-configure.tar.gz_vim_vim_configure" 是一个包含了 Vim 配置文件的压缩包,旨在帮助用户优化 Vim 的使用体验,提供自动提示、补全功能以及代码高亮等特性。 在 Vim 中配置这些功能,可以使编辑效率大幅提升。...

    [ios]Block分离DataSource -ios升级日记2

    2. **设置Block**:在初始化DataSource时,传入Block,例如`self.configureCellBlock = configureBlock;`。 3. **实现DataSource协议**:在DataSource类中实现UITableViewDataSource或UICollectionViewDataSource等...

    Getting Started with Grunt: The JavaScript Task Runner

    Getting Started with Grunt: The JavaScript Task Runner provides you with all the information you need to become an effective Grunt power-user. You will quickly learn how to install, configure, and run...

    Oracle Configure To Order Implementation Manual, Release 11i

    《Oracle Configure To Order Implementation Manual, Release 11i》是一份详尽的指南,由Oracle Corporation出版,旨在为用户和实施团队提供关于如何在企业环境中配置、部署和管理Oracle Configure To Order (CTO)...

    Using autoreconf to Update configure Scripts

    标题“Using autoreconf to Update configure Scripts”涉及的是在开源软件开发中,如何利用`autoreconf`工具来更新配置脚本的过程。`autoreconf`是GNU构建系统的一部分,主要用于自动化配置步骤,确保源代码包能够...

    lidmodbus3.14(解决configure.js错误)

    《libmodbus 3.14:解决configure.js错误详解》 libmodbus是一个流行的开源库,用于实现Modbus通信协议。它支持多种操作系统,包括Linux、Windows和FreeRTOS等,广泛应用于工业自动化、物联网设备以及其他需要进行...

    Linux的Configure参数解释

    - **示例**:如果源代码位于`/path/to/source`,可以使用命令`./configure --srcdir=/path/to/source`。 #### 总结 通过上述介绍,我们可以看到`configure`脚本提供了丰富的选项来满足不同场景下的需求。合理利用...

    MyEclipse,在项目上右键,没有发现Configure菜单问题解决方案

    在myeclipse中,在项目上右键Configure-&gt;Convert to Maven Project,但是现在使用的是MyEclipse,在项目上右键,没有发现Configure菜单

    Qt5 configure参数说明文档

    标题"Qt5 configure参数说明文档"指的是此文档旨在解释和说明如何使用Qt5软件框架中的configure工具的参数。configure是一个用于为特定系统配置源代码树的脚本,以便于编译并安装Qt5及其相关组件。文档中可能会详细...

Global site tag (gtag.js) - Google Analytics