Skip to content

Allow to log errors if "Retrying Complete Batches" happen #2395

@marcin-waldowski-rewe-digital

Description

Expected Behavior

Allow to extend or configure DefaultErrorHandler (which use FixedBackOff.UNLIMITED_ATTEMPTS) in such way that if "Retrying Complete Batches" happen (see spring-kafka documentation) then it is possible to log transient error.

Current Behavior

Spring-kafka logs error only if reties are exhausted. If applications have to retry forever in case of transient error (for example some external application is not available but is needed to process each message) then no errors are logged at all.

There are two solutions for that problem:

  • catch, log and re-throw errors in method annotated with @KafkaListener,
  • extend DefaultErrorHandler and log errors inside of overwritten methods.

The second method works perfectly except when "Retrying Complete Batches" takes place. In this case DefaultErrorHandler methods are not called at all.

Context

This issue stops my team from upgrading from spring-kafka 2.7.* to 2.8.*.
I would prefer to use second solution described above without using fist solution.
I did not find any alternatives to achieve same goal.
The only workaround I found is to use second method and log non-BatchListenerFailedException errors in method annotated with @KafkaListener.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions