Skip to content

Provide synchronous approach to partially commit batch #1915

@daniel-shuy

Description

@daniel-shuy

Affects Version(s): 2.7.3

When using BatchAcknowledgingMessageListener to manually control commits, Acknowledgment#acknowledge() (commit entire batch) will be synchronous/asynchronous depending on whether syncCommits is set to true/false (assuming it is called from the consumer thread and ackMode is AckMode.MANUAL_IMMEDIATE).

But when using Acknowledgment#nack(int, long) to partial commit a batch, the commit is always done asynchronously, regardless of whether syncCommits is true/false. This has 2 downsides:

  • Unless an arbitrarily long sleep time is set, the next poll() might be called before the commits complete, resulting in already successfully processed records being polled again
  • If the Kafka commit fails, it will not give the caller a chance to handle it (eg. rollback database transaction)

While neither of these issues are dealbreaking (consumers should be idempotent), it would be nice to have a way to partially commit synchronously.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions