开发者

LDAP transaction in Java

I have to create a mass insertion feature for our user administration tool. We built a small in-house library using spring LDAP, and everything works fine for single user management (CRUD).

I would like to try to insert hundr开发者_如何学Ceds of records at a time and rollback if something goes wrong.

Is there a way to create transactions in LDAP like it exists in Databases ?

Thanks for your ideas.


This is a followup to @adrianboimvaser.

Just a note that that the Spring LDAP transaction support is not using XA transactions but "Logical" compensating transactions so the rollback of LDAP will be a compensating action against LDAP. While this is an improvement over no transactions be aware that this is not the same as a typical transaction "like it exists in Databases". i.e. The ACID properties of transactions are not supported.

Note that even though the same logical transaction is used, this is not a JTA XA transaction; no two-phase commit will be performed, and thus commit and rollback may yield unexpected results.

For example: If you are adding 100 entries to LDAP each record will be added one by one to LDAP. If the last add fails then the rollback action will be to remove the previously created 99 entries within the transaction. However, if for some reason (e.g. network connectivity is down to LDAP which is what caused the failure for the 100th entry) the first 99 entries cannot actually be removed then even though you have attempted to rollback the transaction you will have an inconsistency between the database and LDAP. i.e. There will be 99 records in LDAP (because they could not be deleted) which do not exist in the database (because those records were never inserted or were actually rolled back).

I'm not sure what your situation is but if you have frequent large updates to LDAP you may want to consider using an actual database to avoid the transaction headaches as well as to optimize performance since LDAP is designed for fast reads with relatively slower writes.


Have a look at the documentation: http://static.springsource.org/spring-ldap/docs/1.2.0-rc1/reference/#transactions

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜