I'm using "Flapdoodle Embedded MongoDB" for integartion test. It works fine. After adding the transaction manager, I have the following error:
org.springframework.data.mongodb.UncategorizedMongoDbException: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.
Here is my application.properties file. I'm not using a connection string for tests. I only added the database version.
de.flapdoodle.mongodb.embedded.version=5.0.5
I tried to add an implementation of AbstractMongoClientConfiguration. But, it didn't fix the issue.
@Configuration
public class EmbededMongoTransactionConfig extends AbstractMongoClientConfiguration {
@Value("${spring.data.mongodb.database}")
private String database;
@Bean
MongoTransactionManager mongoTransactionManager(MongoDatabaseFactory dbFactory) {
return new MongoTransactionManager(dbFactory);
}
@Bean
MongodArguments mongodArguments() {
return MongodArguments.builder().replication(Storage.of(database, 10)).build();
}
@Override
protected String getDatabaseName() {
return database;
}
}
I'm using the following dependencies (springboot 2.7.8):
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>4.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo.spring27x</artifactId>
<version>4.6.0</version>
<scope>test</scope>
</dependency>
Can you help with configuring flapdoodle mongoDb to work with a transaction?
This worked for me:
https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo.spring/blob/main/HowTo.md#transactions
Tough worked well on my local machine whereas failed in docker container. No info on this particular case so far
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With