Reputation: 358
I got a problem to solve with Spring FeignClient.
I have two endpoints to send an SMS, both are the same behavior:
How can I solve this problem?
Today I have an interface with FeignClient annotation and just one URL.
I tried to make use a FeignBuilder to create the request in runtime and change the URL but without success.
How can I use Feign to control service fallback in client side, like:
@Value(${sms.urls})
List<String> endPoints;
for (endPoint : endPoints){
if(endPoint.isUp())
return makeRequest(endPoint).
}
Upvotes: 0
Views: 1094
Reputation: 437
With regards to using FeignBuilder, maybe you can find an answer to your problem here
If this doesn't work, I would suggest creating a wrapper class around the interface.
When I had to deal with such a problem in the past I simply created a class that uses the Feign client interface. Spring will handle the wiring for you based on the fact that you annotated your feign client with the @FeignClient annotation. This way you can modify the behavior from the wrapper class. You'd write your fallback logic in a method and call the feign client as needed.
Hope this helps
Upvotes: 1