Skip to content

Commit

Permalink
feat: enable mongodb transaction manager
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumelamirand committed Jan 7, 2025
1 parent 05d4ee9 commit 07a3cf1
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions docker/quick-setup/https-gateway/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
2 changes: 1 addition & 1 deletion docker/quick-setup/https-nginx/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
mongodb:
image: mongo:${MONGODB_VERSION:-6.0}
restart: always
command: [ "--quiet", "--logpath", "/dev/null" ]
command: ["--replSet", "rs0", "--quiet", "--logpath", "/dev/null" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
1 change: 1 addition & 0 deletions docker/quick-setup/keycloak/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ services:
mongodb:
image: mongo:${MONGODB_VERSION:-6.0}
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
1 change: 1 addition & 0 deletions docker/quick-setup/kibana/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
1 change: 1 addition & 0 deletions docker/quick-setup/mongodb/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
1 change: 1 addition & 0 deletions docker/quick-setup/nginx/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
1 change: 1 addition & 0 deletions docker/quick-setup/opensearch/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
1 change: 1 addition & 0 deletions docker/quick-setup/prometheus/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
1 change: 1 addition & 0 deletions docker/quick-setup/redis-rate-limit/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
1 change: 1 addition & 0 deletions docker/quick-setup/systemProxy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: ["--replSet", "rs0" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
2 changes: 1 addition & 1 deletion docker/quick-setup/tcp/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
image: mongo:${MONGODB_VERSION:-6.0}
container_name: gio_apim_mongodb
restart: always
command: [ "--quiet", "--logpath", "/dev/null" ]
command: ["--replSet", "rs0", "--quiet", "--logpath", "/dev/null" ]
volumes:
- data-mongo:/data/db
- ./.logs/apim-mongodb:/var/log/mongodb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.springframework.core.env.Environment;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.MongoTransactionManager;
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.lang.NonNull;
Expand All @@ -57,7 +59,10 @@ protected AbstractRepositoryConfiguration(Environment environment) {
@Override
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
final ConfigurableListableBeanFactory beanFactory = getConfigurableApplicationContext(applicationContext).getBeanFactory();
beanFactory.registerSingleton("graviteeTransactionManager", new NoTransactionManager());
beanFactory.registerSingleton(
"graviteeTransactionManager",
new MongoTransactionManager(applicationContext.getBean(MongoDatabaseFactory.class))
);
this.applicationContext = applicationContext;
}

Expand Down

0 comments on commit 07a3cf1

Please sign in to comment.