How to configure a MongoDB cluster which supports sessions?

前端 未结 6 731
刺人心
刺人心 2020-12-16 17:32

I want to explore the new transaction feature of MongoDB and use Spring Data MongoDB. However, I get the exception message \"Sessions are not supported by the MongoDB cl

6条回答
  •  感动是毒
    2020-12-16 17:48

    I was having the same issue when I was trying to connect it to a single standalone mongo instance, however as written in the official documentation, that Mongo supports transaction feature for a replica set. So, I then tried to create a replica set with all instances on MongoDB 4.0.0, I was able to successfully execute the code. So, Start a replica set (3 members), then try to execute the code, the issue will be resolved.

    NB : you can configure a replica set on the same machine for tests https://docs.mongodb.com/manual/tutorial/deploy-replica-set-for-testing/

提交回复
热议问题