Reactive MongoDB with Spring boot

MongoDB has changed a lot over the last few years. I have not used it for more than eight years in production now. I recently need to use MongoDB as a multi-purpose data store. It surprised me a lot with the new features, but I was slightly disappointed with the problems of read and write concerns at default settings.  However, you can set it to a majority or a higher level to achieve casual consistency. In this post we are going to cover how to create a spring boot service, connect to Mongo DB with a reactive driver, and perform some queries. I used the freemium Mongo Atlas by signing up and set up a simple cluster on AWS. It is easy to sign up and we can load sample datasets as well. It may take a while to set up the data. Once it is done, head to start.spring.io, add webflux, reactive mongo, and generate the code. If you want to use Lombok, please add that as well. Part 1 – Basics First, we will look at the ReactiveMongoRepository, which is extended from ReactiveCrudRepository. If you’re already familiar with the repository pattern and used spring-data before, then there is

Continue reading