494 questions
0
votes
1
answer
89
views
How to handle multiple exceptions that can be thrown from a @Retryable method in spring
I have a simple Service class that makes call to a third party API to create or update the record. I have 2 separate methods in my service class to make the POST and PUT call. The service class first ...
1
vote
0
answers
64
views
Spring Boot WebClient: Refeshing Access Token when 401 error is thrown. Security Context in the External call is Null
I have a code like this
.retryWhen(Retry.max(3).doBeforeRetry(
retrySignal -> authHeaders.add(HttpHeaders.AUTHORIZATION,
obtainOAuthToken(...
0
votes
0
answers
92
views
Spring Kafka manual ack with async processing: prevent stale offset and lost retries in @RetryableTopic
I'm building a Spring Kafka application that processes messages asynchronously using asynchronous return types. I'm also using @RetryableTopic to handle retries. However, I’m facing an issue where ...
0
votes
1
answer
268
views
Spring @Retryable annotation -- why trying to recover on unmentioned exceptions?
I'm trying to use @Retryable and @Recover and there's clearly something I am missing.
The (very paraphrased, very simplified) code is essentially
// MyRetryableException is a RuntimeException
@...
0
votes
1
answer
113
views
Behavior of Retry in Spring Batch with JdbcCursorItemReader after lost connection
I have some problem.
I need transfer really big amount of data from oracle DB to some other DB.
But in my results always some data is missed.
I have easy query just get two columns from some table.
...
0
votes
1
answer
154
views
How to access current retry interval value?
I am using Spring Retry by creating a RetryTemplate as follows:
import com.example.MyRetryProperties;
import com.example.SomeRetryableException;
import lombok.RequiredArgsConstructor;
import org....
0
votes
1
answer
117
views
@Retryable with a transactional context
I have an issue when two threads try to create an entity in my database.
The first thread checks if the object exists, sees that it is not there, and then creates it. However, at the same time, the ...
0
votes
2
answers
285
views
@Retryable only retrying once in integration test
I've started using the @Retryable annotation in my Spring Boot application (Spring Boot 2.7.18, JDK 21) and it works perfectly fine!
Below are some relevant extracts from the code:
@EnableRetry
@...
0
votes
0
answers
107
views
CircuitBreaker and Retryable on JPA Repository Save function
I would like to introduce Retry and CircuitBreaker mechanism from the database calls. For which I am using SpringRetry and Resilience4j libraries. I have added a code like this and the retry and ...
0
votes
0
answers
571
views
Spring @Retryable is not working on Kotlin suspend fun
I'm trying to add retry logic on my @Service method and it's not working if the method is suspend. (It's Kotlin/Gradle/Spring project).
Below is the working method (just for test):
@Retryable(...
0
votes
1
answer
113
views
Spring Retry @Recover is throwing an UndeclaredThrowableException?
My application has a primary and secondary source for data.
If the main method fails to retrieve data from the primary source, it fallback to the recover method and attempt to search in the secondary ...
0
votes
1
answer
49
views
spring boot retry how to preserve first exception
A retry may lead to a new exception based on the first transaction. To aid in troubleshooting, how to preserve the first error message even if the maximum number of retries is attempted.
Thanks
0
votes
1
answer
390
views
Springboot @Retryable
Springboot version: 3.3.2
Java: 21
import io.cloudevents.CloudEvent;
import java.io.IOException;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.hc.core5.http....
-1
votes
1
answer
1k
views
How to Mock Retryable for a Junit test in springboot
Retryable is not working when I use Mockito in Springboot for a Junit test case
Below is my code
Dao Class:
@Component
public class RetryDao {
public Integer getNumber(String s) throws ...
0
votes
1
answer
308
views
Spring Retry for accessing implementation class name
How can I retrieve the name of the implementation class name from the RetryContext in the onError method of my RetryListener
import org.springframework.retry.annotation.Backoff;
import org....
-1
votes
1
answer
54
views
Which exception is thrown by DataStoreRepository is there's time out or downtime?
I want to implement exponential back off for some errors which appear rarely due to some downtimes in GCP Datastore. My idea is to use @Retryable but I want to catch only the exception related to the ...
1
vote
1
answer
1k
views
Does spring @Retryable create a new connection or use the same connection with server
I have a Spring project wherein I am using @Retryable annotation on a method. The method calls an API and posts some json payload to it.
I have set maxAttempts as 4 and a retry delay of 20 ms using ...
0
votes
1
answer
189
views
How does spring-retry determine which methods to retry when @Retryable is placed at the class level?
I have a @Retryable placed at the class level.
@Import({GrpcClientRetryConfig.class})
@Retryable(interceptor = "grpcClientRetryInterceptor")
@Component
public class Profile {
public void ...
1
vote
1
answer
293
views
How to get the label specified in spring retryable annotation at class level in a MethodInvocationRetryListenerSupport?
I have specified a @Retryable annotation in a spring bean like below.
@EnableRetry
@Import({GrpcClientRetryConfig.class})
@Retryable(interceptor = "grpcClientRetryInterceptor", label = "...
0
votes
1
answer
292
views
Duplicate message coming to @Dlthandler multiple times even after acknowledging msg
I am trying to test @RetryableTopic feature of Kafka where after retrying the message 3 times , I would like to push it to Kafka SQS. I am getting call from retry thread 4 times and call to DltHandler ...
1
vote
2
answers
123
views
Spring Retry Recovery attached to a service activator is not part of the processing chain
I am using a spring integration chain of service activators to process an incoming message from a queue. One of the service activators messagePersister that persists the incoming message. If this ...
1
vote
0
answers
725
views
Spring -@Recover Cannot locate recovery method exception
I am getting Cannot locate recovery method exception while trying to call a method which is annotated as @Retryable, I have created a recover method also with annotation @Recover, But somehow it seems ...
1
vote
1
answer
215
views
Retryable within transaction
I am experiencing a RollbackException being thrown when closing a transaction. For some context, during this transactional there is a retry attempt which is successful.
The structure is like below but ...
0
votes
0
answers
175
views
How can we create a retry mechanism if there is an error in the spring boot db connection?
If there is an error in the db connection while using spring boot, what can be done so that the retry mechanism is activated and the db connection is tried several times?
1
vote
3
answers
2k
views
spring boot retry connecting to database untill connection works
I'm trying to have a spring boot app retry to connect to a database when a connection fails and currently have this:
package backend.configuration.dbconnection;
import lombok.extern.java.Log;
import ...
0
votes
0
answers
83
views
Retry method considering its result
I have some method, that returns object with field boolean done:
public OperationResponse getOperationResponse(YaRequest request) {
// ...
}
class OperationResponse {
boolean done;
}
And if ...
0
votes
0
answers
192
views
Is it possible to add Spring Retry information (counters for number of attempts, successes, failures, timeouts) to Actuator?
I am using the spring-retry dependency and I need to add Spring Retry information (counters for number of attempts, successes, failures, timeouts) to Spring Actuator is this possible? There is also a ...
0
votes
1
answer
924
views
Spock test fails, RetrySynchronizationManager.getContext() is null
I wrote a Spock test to exercise a service using Spring-retry, the test context doesn't get setup correctly somehow.
The specific error is (line breaks inserted by @kriegaex):
[ERROR]
...
0
votes
1
answer
73
views
Spring Retry Junit throws Checked exception is invalid for this method! is thrown
I'm trying to write a unit test for resttemplate.getForEntity() method and trying to cover Exception.class catch block.
Below is the code for same:
import com.google.gson.Gson;
import org.slf4j.Logger;...
1
vote
1
answer
4k
views
Spring @Retryable annotation not working in spring boot application
I'm trying to implement a retry mechanism using spring retry. However, retries are not working.
I have added @EnableRetry annotation in the main class
Below is the code of the service class. I want to ...
0
votes
1
answer
1k
views
Implementing Spring Kafka retry
I have a topic which contains 2 types of messages: one is to create the data and one is to update. I have a situation where some of the update events reaches before create one's. I'm trying to ...
1
vote
0
answers
621
views
Testing Spring Retry with Feign client
I would like to test retries of Spring Retry that I have added to my Feign client.
The problem is that my client looks like this:
@FeignClient(some config)
public interface MyClient {
@PostMapping(...
1
vote
1
answer
3k
views
Problem with exponential backoff in Spring Retry - delayExpression doesn't work with multiplierExpression
I'm trying to add retries to my calls using Spring Retry (newest version).
I've added the following annotation:
@Retryable( maxAttemptsExpression = "${retry.app.maxAttempts}",
...
1
vote
1
answer
620
views
Retry only on specific exception type using RetryTemplate not stopping at max attempt - Java Spring
I am using Retry Template which should retries 5 times on DataAccessResourceFailureException and for every other, No retry.
private static RetryTemplate setupRetryTemplate() { RetryTemplate ...
0
votes
1
answer
93
views
Spring amqp RetryCache is not cleared when AmqpRejectAndDontRequeueException is thrown
I have a simple Rabbit listener which always throws AmqpRejectAndDontRequeueException (to test if listener can handle multiple invalid messages).
The config is:
@RabbitListener(
id = TestConfig....
0
votes
1
answer
827
views
Spring kafka retry delay is shorter than configured
I am using Spring Kafka as retry mechanism. I configured Kafka listener to retryable topic with following code:
@RetryableTopic(
include= {SystemException.class},
...
0
votes
1
answer
232
views
Spring @Retryable - reference thrown exception in delayExpression
I have a service that calls a 3rd party rate-limited API. The API follows the common pattern of returning a 429 response code w/ a Retry-After header containing the amount of time to wait before ...
0
votes
2
answers
2k
views
Spring Retry maxAttempts does not behave and calling more than configured
Trying to configure spring boot retry for simple method. When set maxAttempts = 3 xecuted 9 times. When maxAttempts = 2 executed 4 times. Below is my controller class.
@GetMapping("/...
1
vote
1
answer
2k
views
Can Spring Boot @Retryable work with the Spring Data JPA save() method? My attempt retries once and then fakes success
I am trying to implement retries on the methods of a class that extends JpaRespository. For all the methods annotated with @Query the retries work as expected (3 retries, and then the error is thrown ...
2
votes
1
answer
8k
views
Spring retry, recovery method only for some cases
i need to implement a recovery method that kicks in only in some specific cases. is it possible with Spring Retry? it seems i can't do it using just:
Policy as it can't change an error into a correct ...
0
votes
0
answers
819
views
Can't make Retryable / Recover verify work in Spring Boot Unit Tests
I have a very simple setup for calling an external service and retrying 3 times but I just can't make my Tests to work with Retryable.
In my tests my method only gets called 1 time and stops even ...
2
votes
1
answer
1k
views
SpringBoot RetryListener.onError() invoked without being configured at @Retryable
I am using @Retryable at various service methods. Some of them need some action to be done before the retry happens. I use a RetryListener implementation to achieve this. Well, that ended somehow ...
0
votes
2
answers
1k
views
Spring Retry is not retrying based on exclude keyword
I am using Spring Retry. Earlier, I used @Retryable(value= Exception.class) & it worked correctly with retryAdvice(). The code correctly retried after getting any kind of exception. Recently, we ...
0
votes
1
answer
260
views
Spring RetryTemplate with logging not showing in unit tests
I have a service that uses SLF4J and Spring's RetryTemplate:
retryTemplate.execute(
retryContext -> {
// Try to do something...
return null;
},
...
0
votes
1
answer
365
views
How does Spring Kafka's @Retryable Annotation Implement Asynchronous Exception Handling?
I'm studying Spring Kafka, and I came across the @Retryable annotation, which supposedly implements retry logic asynchronously according to the annotation's comments. However, while examining the code ...
0
votes
1
answer
96
views
Spring Retry - Failing to ignore thread creation processes
I am implementing Spring Retry, specifically for dead-lock scenarios, and there are several threads that get created further within my service (sending emails, etc).
The issue I am facing is the lack ...
2
votes
0
answers
434
views
retryWhen() not working in filter for Spring Reactive
I'm pretty new to using Spring React and have a possibly simple issue here. I have setup a WebClient from a WebClient.Builder. Everything works totally fine except the request is not retried on a ...
1
vote
1
answer
1k
views
Configure default error handler to commit messages after recovery
I would like to retry consuming a message on processing/deserialiation failure for a finite number of times. After the retries are exhausted, I would like to log a message, commit the offset and move ...
0
votes
0
answers
732
views
How to retry 5 times with intervals of 1, 5, 10, 30, 60 seconds using Spring Retry in Java
For example, the method was called at 12:00:00 but failed.
I like it to retry at 12:00:01, 12:00:06, 12:00:16, 12:00:46, 12:01:46
How could I make it happen using Spring Retry in Java
I tried the ...
2
votes
0
answers
663
views
@Retryable not affecting JUnit5 test
I have an simple class to test @Retryable annotation:
@Component
public class SimpleRetryComponent {
private final AtomicLong counter = new AtomicLong(0L);
@Retryable(maxAttempts = 3, backoff = @...