Wow, I've been knee deep in Java Transactions the past few days. I've been trying to get some unit tests running outside of the application server. What I need to do is distributed atomic transactions across two databases. I started out with a framework called JOTM. This turned out to be quite easy to configure together with our existing Spring framework. We could more or less follow examples found on the web and get some code up and running. We could see the transactions starting and committing but when we wanted to roll back we ran out of luck. All logs from spring indicated that the rollback decision was made as expected but the transaction wasn't rolled back. We spent some time banging our heads against the wall and then moved on to the next transaction manager, BitronixTransactionManager. This one was also simple to install and configure but we stumbled upon some weirdness with our DB2 jdbc drivers. This turned out to be because we were using the wrong driverType (should be 4!) so we ditched BTM on unfair grounds and moved on to Atomikos. This was awesome. Since we were all by now experienced in configuring XA datasources, TXmanagers etc it didn't take long at all to wire up the new transaction manager. And you know what? It worked!
Now we'll just see if things keep working when we move the application back into the application server. I guess we'll be reading up on JBossTS the next few days..
I've learned a lot from this. I hadn't touched XA stuff and the only thing I knew about transactions was the stuff I learned from reading database manuals. The whole concept of distributed transactions involving several databases from different vendors is pretty neat.
If you google for JOTM you will probably find some recommendations to stay away from it. You'll get the same recommendation from me, unfortunatly. I can't really understand why it didn't work. I'm still thinking it's because we did something wrong but we didn't really get any clues from the logs or from the documentation.
Tuesday, May 19, 2009
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment