New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-2806 : Receiving an empty list when using RecordFilterStrategy on batch messages #3216
base: main
Are you sure you want to change the base?
GH-2806 : Receiving an empty list when using RecordFilterStrategy on batch messages #3216
Conversation
spring-kafka/src/main/java/org/springframework/kafka/support/Acknowledgment.java
Outdated
Show resolved
Hide resolved
...ng-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java
Outdated
Show resolved
Hide resolved
...ng-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java
Outdated
Show resolved
Hide resolved
I see! i reverted all and make new commits. |
...in/java/org/springframework/kafka/listener/adapter/FilteringBatchMessageListenerAdapter.java
Outdated
Show resolved
Hide resolved
...in/java/org/springframework/kafka/listener/adapter/FilteringBatchMessageListenerAdapter.java
Outdated
Show resolved
Hide resolved
I think the problem comes from the
where we have:
and that leads to the:
So, the logic in that Maybe
|
Thank you for your analysis a lot 🙇♂️🙇♂️🙇♂️🙇♂️! |
I make new commit to apply your reviews. default boolean ignoreEmptyBatch() {
return false;
} I added This way, those who want to be as it is can do so without modifying their codes. Meanwhile, it provides a choice for users who have considered this to be an issue until now. What do you think? |
...in/java/org/springframework/kafka/listener/adapter/FilteringBatchMessageListenerAdapter.java
Outdated
Show resolved
Hide resolved
spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/RecordFilterStrategy.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need some tests for this new feature. And, yes, I also think that this should go to 3.3
already . So, please, fix Javadoc respectively. And add some doc, too.
9e349c2
to
c714551
Compare
@artembilan , thanks for your comments 🙇♂️
I added a couple of test cases to test new public API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The review is a bit thorough, but there is no rush with the fixes.
We have like a month yet until with start a new 3.3
version.
Thanks
Motivation:
batch
mode, even if theRecordFilterStrategy
filters all records resulting in anEmpty List
being returned, theKafkaListener
is still invoked. In contrast, insingle record
mode, ifrecord
are filtered, theKafkaListener
is not called. This difference in behavior between the two modes can cause confusion for users.Modifications:
isAnyManualAck()
toAcknowledgment
to verify thatmanualAck
is needed onFilteringBatchMessageListenerAdapter
.FilteringBatchMessageListenerAdapter
.consumerAware
asfinal
(IMHO, we don't need to calculate it every single callonMessage()
.empty list
andmanual Ack == true
,KafkaListener
will be invoked. ifempty list
andmanual Ack == false
,KafkaListener
will not be invoked even iflistener
is kind ofConsumerAware
. In detail, See Discussion section below.)Result:
RecordFilterStrategy
filters all records and returns an Empty List, theKafkaListener
is invoked only if it is in manualACK
mode.Discussion
ConsumerAware
Listener, commits can be made usingConsumer.commitSync()
andConsumer.commitAsync()
. However, when using aConsumerAwareAckListener
, it seems possible that commits using theConsumer
and commits usingAck
could be processed simultaneously. That situation seems quite ambiguous.