Boot 2.24 + Cloud Hoxton.SR1
I have feign client + consul + spring cloud LB
@FeignClient(name = "payrollClient", url = "http://payroll-compensation")
public interface PayrollClient {
@DeleteMapping(value = "/api/payroll/master/{employee_id}")
ResponseEntity<MasterPayrollResponse> disableMasterPayroll(@PathVariable(name = "employee_id") String employeeId,
@RequestBody MasterPayrollRequest requestBody);
}
Consul runs on localhost.
When I use Hoxton.RELEASE, calling feign method works fine using this caller
@Service
public class UnpaidLeaveService {
@Autowired
private PayrollClient payrollClient;
public boolean approveUnpaidLeave(String employeeId, LocalDate unpaidLeaveDate) {
...
try {
var requestBody = new MasterPayrollRequest();
requestBody.setEffectiveDate(unpaidLeaveDate);
payrollClient.disableMasterPayroll(employeeId, requestBody);
return true;
} catch (FeignException e) {
LOG.warn("[Sync] Feign client Exception : {}", e.getMessage());
return false;
}
...
}
}
Changing the cloud version to SR1 breaks this functionality, when calling through feign client, it throws UnknownHostException.
Attached is the full stack trace, my build.gradle, and application.yml
- stacktrace.txt
- java-config-files.zip
Thanks
Comment From: spencergibb
You shouldn't be using url if you are using discovery
Comment From: timpamungkas
Ok @spencergibb .
Using feign with service discovery does not need url
This implementation works just fine
@FeignClient(name="service-name-on-consul")
Thanks