'maxAttempts is not getting overridden with @StreamRetryTemplate
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
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Oleg Zhurakousky |



