From 6a08091a1dbe7d3536eac9f8c30ae304f966c7dd Mon Sep 17 00:00:00 2001 From: Aryan Singh Date: Sun, 15 Mar 2026 01:08:43 +0530 Subject: [PATCH 1/4] Changes for local setup --- .../src/main/resources/application.yml | 3 ++ .../src/main/resources/application.yml | 3 ++ .../src/main/resources/application.yml | 3 ++ pom.xml | 42 ++++++++++++++++++- 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/customer-service/src/main/resources/application.yml b/customer-service/src/main/resources/application.yml index 7635e64..4b0d096 100644 --- a/customer-service/src/main/resources/application.yml +++ b/customer-service/src/main/resources/application.yml @@ -21,6 +21,9 @@ spring: consul: host: ${CONSUL_HOST:localhost} port: ${CONSUL_PORT:8500} + discovery: + prefer-ip-address: false + hostname: host.docker.internal function: definition: handleReserveCustomerBalanceRequest;handleCompensateCustomerBalanceRequest stream: diff --git a/inventory-service/src/main/resources/application.yml b/inventory-service/src/main/resources/application.yml index 6397041..ea2f338 100644 --- a/inventory-service/src/main/resources/application.yml +++ b/inventory-service/src/main/resources/application.yml @@ -21,6 +21,9 @@ spring: consul: host: ${CONSUL_HOST:localhost} port: ${CONSUL_PORT:8500} + discovery: + prefer-ip-address: false + hostname: host.docker.internal function: definition: handleReserveProductStockRequest stream: diff --git a/order-service/src/main/resources/application.yml b/order-service/src/main/resources/application.yml index fe8939e..f4b2acf 100644 --- a/order-service/src/main/resources/application.yml +++ b/order-service/src/main/resources/application.yml @@ -21,6 +21,9 @@ spring: consul: host: ${CONSUL_HOST:localhost} port: ${CONSUL_PORT:8500} + discovery: + prefer-ip-address: false + hostname: host.docker.internal function: definition: reserveCustomerBalanceStage;reserveProductStockStage stream: diff --git a/pom.xml b/pom.xml index bb34c1d..ef032b2 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ 21 + 1.18.44 2025.0.0 @@ -41,6 +42,21 @@ org.springframework.boot spring-boot-starter-web + + + org.projectlombok + lombok + 1.18.44 + compile + + + + org.projectlombok + lombok-maven + 1.18.20.0 + pom + compile + org.springframework.cloud spring-cloud-stream @@ -59,11 +75,12 @@ spring-boot-configuration-processor true - + org.springframework.boot spring-boot-starter-test @@ -82,4 +99,25 @@ + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + ${java.version} + ${java.version} + + + org.projectlombok + lombok + ${lombok.version} + + + + + + \ No newline at end of file From 0213eb1f86891ad3e25cca9a52658f6291653336 Mon Sep 17 00:00:00 2001 From: Aryan Singh Date: Sun, 15 Mar 2026 01:15:30 +0530 Subject: [PATCH 2/4] Fix Consul service hostname default for local routing --- README.md | 3 +++ customer-service/src/main/resources/application.yml | 2 +- inventory-service/src/main/resources/application.yml | 2 +- order-service/src/main/resources/application.yml | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26b34f1..467c0eb 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ Run services `api-gateway`, `order-service`, `customer-service`, `inventory-serv | Customer service | localhost:9091 | | Inventory service | localhost:9093 | + +> Note: service discovery now defaults to `localhost` for local development. If you run services in Docker and need a different address, set `SERVICE_HOSTNAME` before starting each service (for example `export SERVICE_HOSTNAME=host.docker.internal`). + ### Start outbox connectors Create outbox connectors diff --git a/customer-service/src/main/resources/application.yml b/customer-service/src/main/resources/application.yml index 4b0d096..87aa8c4 100644 --- a/customer-service/src/main/resources/application.yml +++ b/customer-service/src/main/resources/application.yml @@ -23,7 +23,7 @@ spring: port: ${CONSUL_PORT:8500} discovery: prefer-ip-address: false - hostname: host.docker.internal + hostname: ${SERVICE_HOSTNAME:localhost} function: definition: handleReserveCustomerBalanceRequest;handleCompensateCustomerBalanceRequest stream: diff --git a/inventory-service/src/main/resources/application.yml b/inventory-service/src/main/resources/application.yml index ea2f338..a652e93 100644 --- a/inventory-service/src/main/resources/application.yml +++ b/inventory-service/src/main/resources/application.yml @@ -23,7 +23,7 @@ spring: port: ${CONSUL_PORT:8500} discovery: prefer-ip-address: false - hostname: host.docker.internal + hostname: ${SERVICE_HOSTNAME:localhost} function: definition: handleReserveProductStockRequest stream: diff --git a/order-service/src/main/resources/application.yml b/order-service/src/main/resources/application.yml index f4b2acf..8b6c011 100644 --- a/order-service/src/main/resources/application.yml +++ b/order-service/src/main/resources/application.yml @@ -23,7 +23,7 @@ spring: port: ${CONSUL_PORT:8500} discovery: prefer-ip-address: false - hostname: host.docker.internal + hostname: ${SERVICE_HOSTNAME:localhost} function: definition: reserveCustomerBalanceStage;reserveProductStockStage stream: From b783cb64a34d90c7fd773cd849644c6d39bf6e8c Mon Sep 17 00:00:00 2001 From: Aryan Singh Date: Sun, 15 Mar 2026 01:22:36 +0530 Subject: [PATCH 3/4] Use IP-based Consul registration to avoid host.docker.internal failures --- README.md | 3 +++ customer-service/src/main/resources/application.yml | 3 +-- inventory-service/src/main/resources/application.yml | 3 +-- order-service/src/main/resources/application.yml | 3 +-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 26b34f1..9b828a7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ Run services `api-gateway`, `order-service`, `customer-service`, `inventory-serv | Customer service | localhost:9091 | | Inventory service | localhost:9093 | + +> Note: services now register to Consul using their IP address (`prefer-ip-address=true`) instead of a fixed hostname. This avoids `localhost`/`host.docker.internal` mismatches across Docker, host OS, and WSL setups. + ### Start outbox connectors Create outbox connectors diff --git a/customer-service/src/main/resources/application.yml b/customer-service/src/main/resources/application.yml index 4b0d096..d6ad59a 100644 --- a/customer-service/src/main/resources/application.yml +++ b/customer-service/src/main/resources/application.yml @@ -22,8 +22,7 @@ spring: host: ${CONSUL_HOST:localhost} port: ${CONSUL_PORT:8500} discovery: - prefer-ip-address: false - hostname: host.docker.internal + prefer-ip-address: true function: definition: handleReserveCustomerBalanceRequest;handleCompensateCustomerBalanceRequest stream: diff --git a/inventory-service/src/main/resources/application.yml b/inventory-service/src/main/resources/application.yml index ea2f338..353ca9b 100644 --- a/inventory-service/src/main/resources/application.yml +++ b/inventory-service/src/main/resources/application.yml @@ -22,8 +22,7 @@ spring: host: ${CONSUL_HOST:localhost} port: ${CONSUL_PORT:8500} discovery: - prefer-ip-address: false - hostname: host.docker.internal + prefer-ip-address: true function: definition: handleReserveProductStockRequest stream: diff --git a/order-service/src/main/resources/application.yml b/order-service/src/main/resources/application.yml index f4b2acf..2e0f7fc 100644 --- a/order-service/src/main/resources/application.yml +++ b/order-service/src/main/resources/application.yml @@ -22,8 +22,7 @@ spring: host: ${CONSUL_HOST:localhost} port: ${CONSUL_PORT:8500} discovery: - prefer-ip-address: false - hostname: host.docker.internal + prefer-ip-address: true function: definition: reserveCustomerBalanceStage;reserveProductStockStage stream: From 2d3e11fbad33923287a2c4281dcee5f8ca3a82ca Mon Sep 17 00:00:00 2001 From: Aryan Singh Date: Sat, 4 Apr 2026 23:41:33 +0530 Subject: [PATCH 4/4] Changed localhost to docker desktop resolvable dns --- customer-service/src/main/resources/application.yml | 2 +- inventory-service/src/main/resources/application.yml | 2 +- order-service/src/main/resources/application.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/customer-service/src/main/resources/application.yml b/customer-service/src/main/resources/application.yml index 87aa8c4..fae0a1e 100644 --- a/customer-service/src/main/resources/application.yml +++ b/customer-service/src/main/resources/application.yml @@ -23,7 +23,7 @@ spring: port: ${CONSUL_PORT:8500} discovery: prefer-ip-address: false - hostname: ${SERVICE_HOSTNAME:localhost} + hostname: ${SERVICE_HOSTNAME:host.docker.internal} function: definition: handleReserveCustomerBalanceRequest;handleCompensateCustomerBalanceRequest stream: diff --git a/inventory-service/src/main/resources/application.yml b/inventory-service/src/main/resources/application.yml index a652e93..15773b9 100644 --- a/inventory-service/src/main/resources/application.yml +++ b/inventory-service/src/main/resources/application.yml @@ -23,7 +23,7 @@ spring: port: ${CONSUL_PORT:8500} discovery: prefer-ip-address: false - hostname: ${SERVICE_HOSTNAME:localhost} + hostname: ${SERVICE_HOSTNAME:host.docker.internal} function: definition: handleReserveProductStockRequest stream: diff --git a/order-service/src/main/resources/application.yml b/order-service/src/main/resources/application.yml index 8b6c011..f7954ff 100644 --- a/order-service/src/main/resources/application.yml +++ b/order-service/src/main/resources/application.yml @@ -23,7 +23,7 @@ spring: port: ${CONSUL_PORT:8500} discovery: prefer-ip-address: false - hostname: ${SERVICE_HOSTNAME:localhost} + hostname: ${SERVICE_HOSTNAME:host.docker.internal} function: definition: reserveCustomerBalanceStage;reserveProductStockStage stream: