Set up and develop client microservices for Linqra
pom.xml
with the necessary dependencies:
InventoryServiceApplication.java
:
EurekaClientConfig.java
to enable service discovery:
application.yml
with necessary settings:
https://localhost:8761/
.
You should see your service listed in the “Instances currently registered with Eureka” section:
HealthStatus.java
class in the model package:
HealthController.java
class in the controller package:
/api/health
endpoint will return detailed information about your service’s health status, including:
server.port: 0
), you’ll need to check the Eureka dashboard or your service logs to determine the assigned port./api/{resource}
for consistency
@Valid
and constraint annotations
SecurityConfig.java
class to configure Spring Security:
gateway_admin_realm
gateway_admin
(for the linqra-gateway-client
)application.yml
enables client authentication (client-auth: want
)JwtRoleValidationFilter
checks for the presence of required rolesServiceNameInterceptor
adds a service identifier to all outgoing REST calls, which helps with logging, debugging, and request tracing:
RestTemplateConfig
class to set up a pre-configured RestTemplate with our interceptor:
InventoryController
that will house our business logic endpoints:
RestTemplateConfig
provides:
InventoryController
, follow these patterns for standard CRUD operations:
@Valid
annotationsInventoryController
with CRUD operations and service-to-service communication:
HashMap
to store inventory data:
inventoryItems
: Map that stores items with their ID as the keyidCounter
: Atomic counter that ensures unique IDs for new itemsaddMockItem
: Helper method to initialize some sample data/product-availability
endpoint demonstrates service-to-service communication:
GET https://localhost:{port}/inventory-service/api/inventory
GET https://localhost:{port}/inventory-service/api/inventory/1
POST https://localhost:{port}/inventory-service/api/inventory
PUT https://localhost:{port}/inventory-service/api/inventory/1
DELETE https://localhost:{port}/inventory-service/api/inventory/1
GET https://localhost:{port}/inventory-service/api/inventory/product-availability
server.port: 0
. Check the Eureka dashboard or service logs to find the assigned port./product-availability
endpoint will return an error.EC2_SSH_KEY_PROD
: SSH private key for EC2 accessHOST_DNS_PROD
: EC2 instance DNSUSERNAME_PROD
: EC2 username (typically ‘ubuntu’)TARGET_DIR_PROD
: Target directory on EC2