This application developed using Eureka Service Registry, Spring Cloud Gateway, Open Feign for internal communication. For the moment I'm facing an issue with using Feign client to communicate internally between microservices.
This is the Eureka dashboard with registering all the services correctly into the Registry.
Following are the sample properties that I'm using to register these as clients to the Eureka service registry. Registry is running on port 8081.
eureka.client.service-url.defaultZone=http://localhost:8081/eureka
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true
eureka.hostname=localhost
and Here is the Feign client interface to build communication between banking-core-user-service and banking-core-service.
@FeignClient(name = "banking-core-service", configuration = CustomFeignClientConfiguration.class)
public interface BankingCoreFeignClient {
@RequestMapping(method = RequestMethod.GET, value = "/api/v1/user/{identification}")
UserResponse readUser(@PathVariable("identification") String identification);
}
and this is the configuration class for feign client.
package com.javatodev.finance.config;
import com.javatodev.finance.rest.client.CustomFeignErrorDecoder;
import feign.Logger;
import feign.codec.ErrorDecoder;
import feign.okhttp.OkHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class CustomFeignClientConfiguration {
@Bean
public OkHttpClient client() {
return new OkHttpClient();
}
@Bean
Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
}
}
And following is the error response I'm getting when executing communication layer via a API call from postman.
exception occur inside API feign.RetryableException: banking-core-service: nodename nor servname provided, or not known executing GET http://banking-core-service/api/v1/user/808829932V
Seems feign doesn't resolve correct API using Service Discovery. This is working when I'm hard coding banking-core-service IP address and port as the URL property for @FeignClient. But I need to resolve the URL with the name registered in service registry.
