Description
In what version(s) of Spring for Apache Kafka are you seeing this issue?
2.8.11
Describe the bug
With a MessageListenerContainer
configured with FixTxOffsets
set to true
, when all the available messages have been read, the committed offsets do not always match the Last Stable Offsets.
MessageListenerContainer
commits the position of the consumer when records are returned by poll()
for a given partition. If a transaction is then rollbacked on that partition and no other records are available, MessageListenerContainer
does not commit the offsets consumed by the rollbacked transaction, resulting in observable "lag".
To Reproduce
Create and start a MessageListenerContainer
with FixTxOffsets
set to true subscribed to a test topic with a single partition. Create a transactional producer, send a message, wait for the ack and rollback the transaction. The commited offset will be 0, the last stable offset will be 2.
Expected behavior
When all the messages have been consumed, with a MessageListenerContainer
configured with FixTxOffsets
set to true
the committed offsets should track the LSO even when some transactions are rollbacked.