Spring Data MongoDB 4.0事务支持 [英] Spring Data MongoDB 4.0 transactions support

查看:606
本文介绍了Spring Data MongoDB 4.0事务支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MongoDB 4.0将引入具有ACID保证的交易支持.

MongoDB 4.0 are going to introduce transactions support with ACID guarantees.

Spring Data MongoDB是否已支持MongoDB中的事务,如果不支持,那么此功能将可用.考虑到以下问题,我确实很需要它- MongoDB模式设计,以支持应用程序水平扩展

Does Spring Data MongoDB already supports the transactions in MongoDB and if no, when this awesome feature will be available. I really need it, taking into account the following issue - MongoDB schema design in order to support application horizontal scaling

推荐答案

Spring Data MongoDB是否已经支持MongoDB中的事务

Does Spring Data MongoDB already supports the transactions in MongoDB

Spring Data Lovelace M3(2.1.0.M3)支持于2018年5月17日发布的MongoDB v4.0的同步事务.另请参见

Spring Data Lovelace M3 (2.1.0.M3) supports synchronous transaction for MongoDB v4.0, released on May 17th 2018. See also Spring Data Lovelace M3 release notes.

来自的示例Spring Data文档:MongoDB事务

ClientSession session = client.startSession(options);                   

template.withSession(session)
    .execute(action -> {
        session.startTransaction();                                     
        try {

            Step step = // ...;
            action.insert(step);
            process(step);
            action.update(Step.class).apply(Update.set("state", // ...
            session.commitTransaction();                                
        } catch (RuntimeException e) {
            session.abortTransaction();                                 
        }
    }, ClientSession::close)                                            
    .subscribe();

另请参阅相关内容: DATAMONGO-1920

See also related: DATAMONGO-1920 and DATAMONGO-1970

这篇关于Spring Data MongoDB 4.0事务支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆