Skip to content

Make ContainerPausingBackOffHandler working in batch mode. #3712

Open
@user734879

Description

@user734879

In what version(s) of Spring for Apache Kafka are you seeing this issue?

3.3.1

Describe the bug

Intention was to process entire batch of messages as a single entity and retry it several times, then skip/recover entire batch if all retries exhausted.

Throwing BatchListenerFailedException is not applicable since

Documentation suggests throwing non BatchListenerFailedException and it works only if backoff time is less than max.poll.interval. When delays are longer it causes rebalancing since FallbackBatchErrorHandler sleeps for backoff time between poll operations. Configuring ContainerPausingBackOffHandler as a backoff error handler in order to handle long delays does not have impact.

To Reproduce

Use batch Kafka listener which throws non-BatchListenerFailedException to retry entire batch of events.

Expected behavior

ContainerPausingBackOffHandler is applied when non-BatchListenerFailedException error is thrown.

Sample

Configuration of ErrorHandler:

final ExponentialBackOff backOff = new ExponentialBackOff(A, B);
backOff.setMaxInterval(C); // longer than max.poll.interval
backOff.setMaxElapsedTime(X);
return new DefaultErrorHandler(null, backOff, new ContainerPausingBackOffHandler(new ListenerContainerPauseService(null, taskScheduler));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions