Reputation: 6256
I am using spring-cloud-stream 3.2.2 with kafka binder and I am defining a custom retryTemplate to override the default maxAttempts (3) and disable retrying
@StreamRetryTemplate
public RetryTemplate retrier() {
var retry = new RetryTemplate();
retry.setRetryPolicy(new SimpleRetryPolicy(1, new HashMap<>()));
return retry;
}
But when an exception occurs in the consumer still retries 3 times instead of just 1 time
the custom retryTemplate bean doesn't get injected
Upvotes: 1
Views: 853
Reputation: 6126
You must also specify retry-template-name
per binding:
https://docs.spring.io/spring-cloud-stream/docs/3.2.2/reference/html/spring-cloud-stream.html#_retry_template
For example:
spring.cloud.stream.bindings.uppercase-in-0.consumer.retry-template-name=retrier
Upvotes: 0