Hayi
Hayi

Reputation: 6256

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

enter image description here

the custom retryTemplate bean doesn't get injected

enter image description here

enter image description here

Upvotes: 1

Views: 853

Answers (1)

Oleg Zhurakousky
Oleg Zhurakousky

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

Related Questions