I\'m currently working on a Spring Boot microservices project. I have created services and each service is running separately. With this, I need some services to communicate wit
@Autowired
private RestTemplate restTemplate;
@Autowired
private EurekaClient eurekaClient;
@RequestMapping("/dashboard/{myself}")
public EmployeeInfo findme(@PathVariable Long myself) {
Application application = eurekaClient.getApplication(employeeSearchServiceId);
InstanceInfo instanceInfo = application.getInstances().get(0);
String url = "http://" + instanceInfo.getIPAddr() + ":" + instanceInfo.getPort() + "/" + "employee/find/" + myself;
System.out.println("URL" + url);
EmployeeInfo emp = restTemplate.getForObject(url, EmployeeInfo.class);
System.out.println("RESPONSE " + emp);
return emp;
}
source: https://dzone.com/articles/microservices-communication-service-to-service