In the documentation of the spring-cloud-stream project the only retry mechanism that I have saw was a single backoff policy.
The behavior that I would like to achieve is three different retry policies in case that an exception is thrown while consuming a message:
Is there a way to define a different retry policy for each kind of exception? I know that in spring-kafka there was an ability to provide a RetryTemplate and achieve the above-mentioned behavior.
I thought that maybe with the DLQ mechanism there would be a way to achieve this behavior.
Edit: I am using Kafka as the messaging middleware.
From Spring Cloud Stream 2.0.0 upwards you can define your own RetryTemplate
:
@StreamRetryTemplate
public RetryTemplate myRetryTemplate() {
return new RetryTemplate();
}
Full doc here : https://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/#_retry_template