Proper XA Transactions With Oracle and Spring

Whats this all about?

There are a load of places on the internet that give partial solutions to this common problem: XA Transactions, outside an application container. Here's an attempt to put them all in one place.

Context

This uses the following technologies.

Selecting the correct oracle drivers

You will need to use the 11.1.0.6.0 11g drivers. These are suitable for previous versions of oracle.

Previous 10.x version of the drivers have a connetion/resource leak which will bite when you use XA.

Configuring Oracle for XA Transactions

Oracle out-of-the-box does not come configured suitable for XA transactions. You need to run the following as a SYS user.

Setting up the transaction manager

Setting up the data source

Sweet!

Actually that's it.

The "allowLocalTransactions" setting means that you can do stuff outside a global transaction. This isn't really recommended, but will work.

Using all this inside tests.

You must remember to destroy your application context each time you create it. Otherwise the transaction manager will grumble at being created multiple times.

Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account. You can also Sign Up for a new account.


Browse Space

- Pages
- Blog
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced
- Activity

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

 

Other Features

Add Content

- Add Comment