MongoDB 4 provides transactions, but requires replica sets. Therefore, the clearly arranged properties database
, host
, username
, password
, authentication-database
etc. cannot be used, but only the longish uri
property where all these props have to be combined incl. the specified replica set.
IMO it would be nice to have an additional property e.g. spring.data.mongodb.replica-set
.
Furthermore, the password
can be specified separately and can easily be encoded when using Spring Cloud Config to serve the database props.
Comment From: mp911de
On a related note: For R2DBC we went ahead and allow username/password credentials to be supplied as individual properties so that they can be supplied externally instead of being part of the URL. That pattern was proved to work well so maybe also applicable here.
Regarding the replica set, it makes sense to include this property for an improved experience with MongoDB transactions. A future MongoDB version is going to ship with transactional support for sharded clusters. However, we should also cater for the current production versions that impose the replica set restriction.