Here is how this situation can be theoretically considered. First you need to have several distributed JTA transaction managers on each node. One acts as a master, the other as slaves. The wizard coordinates the commit / rollback of the distributed transaction with subordinates. There are standalone JTA implementations, for example. JOTM .
Vanilla RMI does not support the dissemination of contextual information, such as transaction transaction identifier. But I think RMI has hooks so that it can be expanded to support this. You can watch Carol .
You will need to use XAResource to wrap the participants in the transaction so that they can be credited to the distributed transaction. The master will have to send commit / rollback messages to the slaves, which the XATerminator will have to use in order to act accordingly.
The JTA specification is just a distributed transaction manager; transaction logging in the transaction log should be done by servers. A library exists to manage a transaction log, for example. Howl .
I don't think Spring can be used - even with a distributed transaction manager - to do this easily. I once tried using RMI with a distributed transaction managed by a standalone client and several subordinates. Here is about this blog . It was quite difficult.
You can get all this for free if you use the Java EE application server with IIOP. IIOP supports the distribution of distributed transactions. A client can be a client application container , and you can control transactions using UserTransaction . This is actually one of the rare cases when I think that using the application server is really justified.
But this suggests that a distributed transaction is complex things that can lead to heuristic failures, a timeout if one of the nodes dies, and complex recovery procedures.
My last piece of advice would be: try to find a construct that is not related to a distributed transaction, if possible. It will make you a lot easier.
You can breathe inspiration into the BPEL compensation mechanism . Perhaps there are other approaches to error handling and reliability that can avoid the use of distributed transactions.
ewernli
source share