I am working on 3 spring boot application from which 2 applications i am using for communication between the two i am using feign client also i am 1 application for api-gateway which has all the entries for diffrent application feign client controller is
@Autowired
PaymentService paymentService;
@PostMapping(value = "/payments/{appointmentId}")
public String changePaymentStatus(@PathVariable(name = "appointmentId")String appointmentId){
paymentService.changePaymentStatus(appointmentId);
return "Done";
}
here is the feign client code
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(name = "API-GATEWAY")
public interface AppointmentServiceClient {
@RequestMapping(value = "${appointmentApp.changePaymentStatus}",method = RequestMethod.POST)
public String changePaymentStatus(@PathVariable(name = "appointmentId")String appointmentId);
}
Here i have used "API-GATEWAY" because the there is one application running with this name and its application.yml file is here
port: 9191
spring:
application:
name: API-GATEWAY
cloud:
gateway:
routes:
- id: DOCTOR-SERVICE
uri: lb://DOCTOR-SERVICE
predicates:
- Path=/doctor_app/**
- id: APPOINTMENT-SERVICE
uri: lb://APPOINTMENT-SERVICE
predicates:
- Path=/appointment_app/**
- id: USER-ON-BOARDING-SERVICE
uri: lb://USER-ON-BOARDING-SERVICE
predicates:
- Path=/user_app/**
- id: RATING-SERVICE
uri: lb://RATING-SERVICE
predicates:
- Path=/rating_app/**
- id: PAYMENT-SERVICE
uri: lb://PAYMENT-SERVICE
predicates:
- Path=/payment_app/**
discovery:
enabled: true
Also the value in @RequestMapping of AppointmentServiceClient has application.properties as shown here
appointmentApp.address = http://APPOINTMENT-SERVICE
appointmentApp.changePaymentStatus = /appointment_app/v1/payments/{appointmentId}
Here i am want to call APPOINTMENT-SERVICE through api-gateway using feign client
Also the controller method which the feign client is trying to call is
@PostMapping(value = "/v1/payments/{appointmentId}")
public String changePaymentStatus(@PathVariable(name = "appointmentId")String appointmentId){
appointmentService.changePaymentStatus(appointmentId);
return "done";
}
By doing a POST from postman i am getting feign.FeignException$ServiceUnavailable: [503] during [POST] to [http://API-GATEWAY/appointment_app/v1/payments/ndjkccbc7868] [AppointmentServiceClient#changePaymentStatus(String)]: [Load balancer does not contain an instance for the service API-GATEWAY]