From 9abb66af12b3824bfad320e638572371fbae2d1f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 09:17:40 +0000 Subject: [PATCH 1/2] chore(deps): update mongo docker tag to v7.0.5 --- .../docker/docker-compose-cluster.yml | 6 +++--- boot-mongodb-elasticsearch/docker/docker-compose.yml | 2 +- docker-compose.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boot-mongodb-elasticsearch/docker/docker-compose-cluster.yml b/boot-mongodb-elasticsearch/docker/docker-compose-cluster.yml index cb9b828cc..310e1f783 100644 --- a/boot-mongodb-elasticsearch/docker/docker-compose-cluster.yml +++ b/boot-mongodb-elasticsearch/docker/docker-compose-cluster.yml @@ -4,7 +4,7 @@ services: mongo1: container_name: mongo1 hostname: mongo1 - image: mongo:6.0.13 + image: mongo:7.0.5 extra_hosts: - "host.docker.internal:host-gateway" - "docker.for.win.host.internal:host-gateway" @@ -20,7 +20,7 @@ services: mongo2: container_name: mongo2 hostname: mongo2 - image: mongo:6.0.13 + image: mongo:7.0.5 extra_hosts: - "host.docker.internal:host-gateway" - "docker.for.win.host.internal:host-gateway" @@ -33,7 +33,7 @@ services: mongo3: container_name: mongo3 hostname: mongo3 - image: mongo:6.0.13 + image: mongo:7.0.5 extra_hosts: - "host.docker.internal:host-gateway" - "docker.for.win.host.internal:host-gateway" diff --git a/boot-mongodb-elasticsearch/docker/docker-compose.yml b/boot-mongodb-elasticsearch/docker/docker-compose.yml index 6fb645ba1..d3005e57a 100644 --- a/boot-mongodb-elasticsearch/docker/docker-compose.yml +++ b/boot-mongodb-elasticsearch/docker/docker-compose.yml @@ -3,7 +3,7 @@ version: "3.9" services: mongodb: hostname: mongodb - image: mongo:6.0.13 + image: mongo:7.0.5 volumes: - mongodb:/data/db ports: diff --git a/docker-compose.yml b/docker-compose.yml index 47237db1f..ac4df1da5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -65,7 +65,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock mongodb: - image: mongo:7.0.2 + image: mongo:7.0.5 ports: - "27017:27017" volumes: From 6b30835cd2fa9fbfa60bfcc4b08924a88275585f Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Mon, 19 Feb 2024 09:28:42 +0000 Subject: [PATCH 2/2] changes to fix starting app --- boot-mongodb-elasticsearch/docker/docker-compose.yml | 3 ++- boot-mongodb-elasticsearch/pom.xml | 2 +- .../example/mongoes/web/controller/RestaurantController.java | 4 ++-- .../com/example/mongoes/web/service/RestaurantService.java | 2 +- .../src/test/java/com/example/mongoes/TestApplication.java | 3 +-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/boot-mongodb-elasticsearch/docker/docker-compose.yml b/boot-mongodb-elasticsearch/docker/docker-compose.yml index d3005e57a..d0cd78b2d 100644 --- a/boot-mongodb-elasticsearch/docker/docker-compose.yml +++ b/boot-mongodb-elasticsearch/docker/docker-compose.yml @@ -9,7 +9,8 @@ services: ports: - "27017:27017" healthcheck: - test: test $$(echo "rs.initiate().ok || rs.status().ok" | mongo --quiet) -eq 1 + test: | + mongosh --eval "try { rs.status().ok } catch (e) { rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'localhost:27017' }] }).ok }" interval: 10s start_period: 30s command: ["/usr/bin/mongod", "--replSet", "rs0", "--bind_ip_all"] diff --git a/boot-mongodb-elasticsearch/pom.xml b/boot-mongodb-elasticsearch/pom.xml index e926f7536..2558fbecc 100644 --- a/boot-mongodb-elasticsearch/pom.xml +++ b/boot-mongodb-elasticsearch/pom.xml @@ -229,7 +229,7 @@ - 1.17.0 + 1.19.2 diff --git a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/controller/RestaurantController.java b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/controller/RestaurantController.java index 062277379..e4d1ac0ac 100644 --- a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/controller/RestaurantController.java +++ b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/controller/RestaurantController.java @@ -32,8 +32,8 @@ public class RestaurantController { @GetMapping public Mono>> findAllRestaurants( - @Valid @RequestParam(defaultValue = "10") @Size(max = 999) Integer limit, - @RequestParam(defaultValue = "0") Integer offset) { + @Valid @RequestParam(defaultValue = "10") @Size(max = 999) int limit, + @RequestParam(defaultValue = "0") int offset) { return restaurantService.findAllRestaurants(offset, limit).map(ResponseEntity::ok); } diff --git a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/RestaurantService.java b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/RestaurantService.java index 60e94c384..d854b33a5 100644 --- a/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/RestaurantService.java +++ b/boot-mongodb-elasticsearch/src/main/java/com/example/mongoes/web/service/RestaurantService.java @@ -203,7 +203,7 @@ private List getResumeToken() { return this.changeStreamResumeRepository.findAll().toStream().toList(); } - public Mono> findAllRestaurants(Integer offset, Integer limit) { + public Mono> findAllRestaurants(int offset, int limit) { Sort sort = Sort.by(Sort.Direction.DESC, "restaurant_id"); Pageable pageable = PageRequest.of(offset, limit, sort); return this.restaurantESRepository.findAll(pageable); diff --git a/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/TestApplication.java b/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/TestApplication.java index ba9a21c39..2ce95e715 100644 --- a/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/TestApplication.java +++ b/boot-mongodb-elasticsearch/src/test/java/com/example/mongoes/TestApplication.java @@ -25,8 +25,7 @@ ElasticsearchContainer elasticsearchContainer() { @Bean @RestartScope MongoDBContainer mongoDBContainer() { - return new MongoDBContainer(DockerImageName.parse("mongo").withTag("6.0.12")) - .withSharding(); + return new MongoDBContainer(DockerImageName.parse("mongo").withTag("7.0.5")).withSharding(); } public static void main(String[] args) {