I have following situation:
I have Alfresco JCR as a server, and Jackrabbit JCR Api exposed over RMI to the client. (Alfresco is using spring+hibernate.) I need to implement transactions in client side. Or actually it's the server side where the transaction should really be, and I just need to start and commit it from client.
There's some sample code from client side:
ClientRepositoryFactory factory = new ClientRepositoryFactory();
Repository repository = factory.getRepository(rmiUrl);
SimpleCredentials credentials = new SimpleCredentials("admin", "admin".toCharArray());
Session session = repository.login(credentials);
/* this all needs to happen inside SAME transaction in server side: */
RemoteTransactionService.beginTransaction(); // this kind of call could propably do the job
Node rootNode = session.getRootNode(); // this results in some operations in server over rmi
rootNode.doSomething(); // this results in some operations in server over rmi
rootNode.doSomethingElse(); // this results in some operations in server over rmi
RemoteTransactionService.commitTransaction(); // this kind of call could propably do the job
So I kind of do *not* need distributed transactions, I believe, but a way to tell the server that 'all the operations made in these rmi calls need to happen in the same transaction there in the server'.
I tested exporting begin/commit operations to the client over RMI just like in above sample code, but this does not work because rmi calls happen in different threads in server side, and the server side transaction (and hibernate session) is bound to thread.
Team Leader / Quosis Ltd