0

I would like to join two operations in one transaction.

Operations->

Op. 1/ I need to save a user on a mongodb database. I'm using this library in order to persist data on this database. After that, ...

Op. 2/ I need to save some of this user information on a openldap server. I'm using this library in order to connect with a openldap instance.

So, as you might be figuring out, I need to ensure both operations has been performem well.

So,

1) Operation 1:ok, and 2nd:ok have been right -> No problem -> Tx.commit();

2) Operation 1:ok, and 2nd:ko -> Problem -> I need to rollback first operation. -> Tx.rollback();

3) Operation 1:ko -> Tx.rollback();

The environtment of these operations are inside a Servlet in a J2EE Servlet Container 3.1.

I have no idea how to do that.

Jordi
  • 20,868
  • 39
  • 149
  • 333
  • This is a really broad question in essence, but I'll at least try to give you some pointers. The general concept of implementing "transaction handling" in your "data facing layer" is the correct approach. The storage engines you are talking about here do not support any concept of "rollback" since there is no native transaction handling. You are in fact "on your own" to do so and "manually undo" any written operations what might not conform to the "transaction". So welcome to NoSQL. The benefit is things done better than SQL. The "trade off" is you need to do the rest your self. –  Jun 12 '15 at 13:09
  • Perhaps, my question should be posed as follows: 1) Can I use JTA or any transaction api in order to wrap a untransactional operation? and 2) Does it exist any standard approach in order to solve my main question? – Jordi Jun 13 '15 at 16:34
  • RFC 5805 specifies transaction support in LDAP. The feature will be in the OpenLDAP 2.5 release. You would need an XA manager to coordinate txns between OpenLDAP and some other storage system. – hyc Jun 22 '15 at 18:57

0 Answers0