You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Team,
we need to implement retry on HTTP Status code(eg: for 429, 500, 502, 503, 504) for API call. Is there any library in Helidon(using 3.2) or any other library which we can use to have retry on these status code? Retry can be both linear and exponential too. I checked the faultTolerance lib in helidon and it provides annotations based retry but it only retries based on exception type.
If there is no such library, Could this be implemented in future releases of helidon ? @Retry(maxRetries=3, delay=1000, retryOn={Exception.class})
Thanks,
Sammee
The text was updated successfully, but these errors were encountered:
There's one way to support a similar use case using existing features in Rest Client and Fault Tolerance. Rest Client has the notion of a ResponseExceptionMapper, which can be used to map a Response to an Exception. For example,
In this example, and mainly for simplicity, any status code other than 200 is mapped to an instance of MyException (naturally, different error codes could be mapped to different exception types). This mapper can be registered as a provider in a client and used with the normal FT @Retry:
Thus, any time MyException is thrown, the exception will be caught by the FT handler and the method retried up to 3 times (the default for that annotation).
I understand this may not be as convenient as having a dedicated annotation for this purpose, but it is possible using existing constructs and extensions.
@spericas I have implemented a variant of this. Using ResponseMapper will throw a custom exception for a particular status code. This will be applied for all Rest clients. Instead, I wanted to have retry on some specific api. So i have used @Retry annotation on the method where the api is called and throw a custom exception when the status-code or error is retryable.
Thanks for the suggestion.
Hi Team,
we need to implement retry on HTTP Status code(eg: for 429, 500, 502, 503, 504) for API call. Is there any library in Helidon(using 3.2) or any other library which we can use to have retry on these status code? Retry can be both linear and exponential too. I checked the faultTolerance lib in helidon and it provides annotations based retry but it only retries based on exception type.
If there is no such library, Could this be implemented in future releases of helidon ?
@Retry(maxRetries=3, delay=1000, retryOn={Exception.class})
Thanks,
Sammee
The text was updated successfully, but these errors were encountered: