Skip to content

Instantly share code, notes, and snippets.

@timjonesdev
Created August 20, 2019 22:31
Show Gist options
  • Select an option

  • Save timjonesdev/357dd1716eb135bcab78fa8c0039ca00 to your computer and use it in GitHub Desktop.

Select an option

Save timjonesdev/357dd1716eb135bcab78fa8c0039ca00 to your computer and use it in GitHub Desktop.
Extend the AbstractReactiveMongoConfiguration
import com.mongodb.reactivestreams.client.MongoClient;
import com.mongodb.reactivestreams.client.MongoClients;
import org.springframework.context.annotation.Bean;
import org.springframework.data.mongodb.config.AbstractReactiveMongoConfiguration;
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories;
/**
* Config class to set up necessary components for watching the MongoDB change stream
*/
@EnableReactiveMongoRepositories
public class ReactiveMongoConfig extends AbstractReactiveMongoConfiguration {
@Bean
public MongoClient reactiveMongoClient() {
return MongoClients.create();
}
@Bean
public String getDatabaseName() {
return "fantasy_db";
}
@Bean
public ReactiveMongoTemplate reactiveMongoTemplate() {
return new ReactiveMongoTemplate(reactiveMongoClient(), getDatabaseName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment