Commit bf7659f9 authored by Alex Segers's avatar Alex Segers

[AFP-134] 🔧 Add MongoDB config for ReactiveMongoTemplate creation used in orders pagination

parent 1aef3e57
package com.afp.ordermanagement.config;
import com.mongodb.reactivestreams.client.MongoClient;
import com.mongodb.reactivestreams.client.MongoClients;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
import org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory;
@Configuration
public class MongoConfig {
@Value("${spring.data.mongodb.database}")
public String databaseName;
@Bean
public SimpleReactiveMongoDatabaseFactory reactiveMongoDbFactory() {
MongoClient mongoClient = MongoClients.create();
return new SimpleReactiveMongoDatabaseFactory(mongoClient, databaseName);
}
@Bean
public ReactiveMongoTemplate reactiveMongoTemplate() throws Exception {
ReactiveMongoTemplate mongoTemplate = new ReactiveMongoTemplate(reactiveMongoDbFactory());
return mongoTemplate;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment