title: Feign client and Spring retry
body: <p>I have a restful service calling an external service using Spring Cloud Feign client</p>
  
  <pre><code>@FeignClient(name = "external-service", configuration = FeignClientConfig.class)
  public interface ServiceClient {
  
      @RequestMapping(value = "/test/payments", method = RequestMethod.POST)
      public void addPayment(@Valid @RequestBody AddPaymentRequest addPaymentRequest);
  
      @RequestMapping(value = "/test/payments/{paymentId}", method = RequestMethod.PUT)
      public ChangePaymentStatusResponse updatePaymentStatus(@PathVariable("paymentId") String paymentId,
              @Valid @RequestBody PaymentStatusUpdateRequest paymentStatusUpdateRequest);
  
  }
  </code></pre>
  
  <p>I noticed the following failure 3-4 times in the last 3 months in my log file:</p>
  
  <blockquote>
    <p>json.ERROR_RESPONSE_BODY:Connection refused executing POST
    <a href="http://external-service/external/payments" rel="noreferrer">http://external-service/external/payments</a> json.message:Send Payment
    Add Payment Failure For other reason: {ERROR_RESPONSE_BODY=Connection
    refused executing POST <a href="http://external-service/external/payments" rel="noreferrer">http://external-service/external/payments</a>,
    EVENT=ADD_PAYMENT_FAILURE, TRANSACTION_ID=XXXXXXX} {}
    json.EVENT:ADD_PAYMENT_FAILURE
    json.stack_trace:feign.RetryableException: Connection refused
    executing POST <a href="http://external-service/external/payments" rel="noreferrer">http://external-service/external/payments</a> at
    feign.FeignException.errorExecuting(FeignException.java:67) at
    feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:104)
    at
    feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
    at
    feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)</p>
  </blockquote>
  
  <p>Is it possible to add Spring Retry on a Feign client.
  What I wanted to annotate the <code>addPayment</code> operation with </p>
  
  <pre><code>@Retryable(value = {feign.RetryableException.class }, maxAttempts = 3, backoff = @Backoff(delay = 2000, multiplier=2))
  </code></pre>
  
  <p>But this is not possible, what other options do I have?</p>