I have a Spring Cloud Stream project using the Kafka binder and I'm trying to understand and eventually customize the RetryTemplate used by Cloud Stream.
I'm not finding a lot of documentation on how this works, but what I've read leads me to the following assumptions:
- Cloud Stream configures and enables Spring Retry by default, including default retry and backoff policies.
- By default, any uncaught exception in a
@StreamListener
will trigger Spring Retry - Cloud Stream will somehow track RetryContext information for each message (how? I'm not sure)
Are these assumptions correct?
Now, in my application, I have a pattern where some messages can be handled immediately, but others must be deferred to be tried again later (using exponential backoff etc).
Should I be throwing an exception causing Spring Cloud Stream to retry these messages at the binder layer, or implementing retry myself and tracking my own retry contexts?
If I should be relying on Cloud Stream's retry setup, how should I customize the backoff policies, etc?