이 때, contextId
를 설정해주면 중복 문제를 방지할 수 있다.
변경 전,@FeignClient(name = "productClient", url = "http://localhost:8082/api/internal/products")
public interface ProductClient {
@GetMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
ProductResponse getProduct(@PathVariable(value = "id") Long id);
}
@FeignClient(name = "stockClient", url = "http://localhost:8082/api/internal/stocks")
public interface StockClient {
@PostMapping(value = "/decrease/all", consumes = MediaType.APPLICATION_JSON_VALUE)
void decreaseAllStock(StockAllRequest request);
@PostMapping(value = "/increase/all", consumes = MediaType.APPLICATION_JSON_VALUE)
void increaseAllStock(StockAllRequest request);
}
변경 후,@FeignClient(name = "PRODUCT-MODULE", contextId = "productClient", path = "/api/internal/products")
public interface ProductClient {
@GetMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
ProductResponse getProduct(@PathVariable(value = "id") Long id);
}
@FeignClient(name = "PRODUCT-MODULE", contextId = "stockClient", path = "/api/internal/stocks")
public interface StockClient {
@PostMapping(value = "/decrease/all", consumes = MediaType.APPLICATION_JSON_VALUE)
void decreaseAllStock(StockAllRequest request);
@PostMapping(value = "/increase/all", consumes = MediaType.APPLICATION_JSON_VALUE)
void increaseAllStock(StockAllRequest request);
}