3

Is it possible to add a property to the application.yml to include/exclude certain exceptions from being retried in the policy defined below? I swear that I read somewhere that there is a property for this, but now I cannot find it again for the life of me. Any help would be appreciated.

spring:
  cloud:
    stream:
      kafka:
        binder:
          brokers: localhost:9092
      bindings:
        topic-in:
          destination: topic
          contentType: application/json
          group: topic-group
          consumer:
            max-attempts: 3 
            backOffInitialInterval: 1000
            backOffMaxInterval: 1000
            backOffMultiplier: 3
Gary Russell
  • 166,535
  • 14
  • 146
  • 179

1 Answers1

1

See the documentation Retry Template.

The RetryTemplate is part of the Spring Retry library. While it is out of scope of this document to cover all of the capabilities of the RetryTemplate, we will mention the following consumer properties that are specifically related to the RetryTemplate:

...

defaultRetryable

Whether exceptions thrown by the listener that are not listed in the retryableExceptions are retryable.

Default: true.

retryableExceptions

A map of Throwable class names in the key and a boolean in the value. Specify those exceptions (and subclasses) that will or won’t be retried. Also see defaultRetriable. Example: spring.cloud.stream.bindings.input.consumer.retryable-exceptions.java.lang.IllegalStateException=false.

Default: empty.

...

While the preceding settings are sufficient for majority of the customization requirements, they may not satisfy certain complex requirements at, which point you may want to provide your own instance of the RetryTemplate. To do so ...

Community
  • 1
  • 1
Gary Russell
  • 166,535
  • 14
  • 146
  • 179