Skip to content
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-3660: Fix EmbeddedKafkaBroker seekToEnd #3661

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

coekie
Copy link
Contributor

@coekie coekie commented Dec 8, 2024

Fixes #GH-3660

Problem:
consumeFromEmbeddedTopics calls Consumer.seekToEnd, which "evaluates lazily, seeking to the final offset in all partitions only when poll(Duration) or position(TopicPartition) are called". This means that the consumer may or may not see future messages, depending on timing.

This fix calls position so that the seek happens before consumeFromEmbeddedTopics returns. That was it is ensured that any message sent to the topic after the call to consumeFromEmbeddedTopics are seen by the consumer.

I did not see tests yet for the consume methods in EmbeddedKafkaBroker, so I'm not entirely sure if this is the approach you would want for the tests. The tests are inspired by tests in KafkaTestUtilsTests.

@sobychacko
Copy link
Contributor

@coekie Changes look good. Can you add your name as an author to all the classes you changed?

Problem:
consumeFromEmbeddedTopics calls Consumer.seekToEnd, which
"evaluates lazily, seeking to the final offset in all partitions only
when poll(Duration) or position(TopicPartition) are called".
This means that the consumer may or may not see future messages,
depending on timing.

This fix calls `position` so that the seek happens before
consumeFromEmbeddedTopics returns. That was it is ensured that any
message sent to the topic after the call to consumeFromEmbeddedTopics
are seen by the consumer.

Issue: spring-projects#3660
@coekie coekie changed the title GH-3660: Fix EmbeddedKafkaBrokers.seekToEnd GH-3660: Fix EmbeddedKafkaBroker seekToEnd Dec 10, 2024
@coekie
Copy link
Contributor Author

coekie commented Dec 10, 2024

@sobychacko Great. I just added myself as author (and tweaked the commit/PR title)

@sobychacko sobychacko merged commit fe71001 into spring-projects:main Dec 12, 2024
3 checks passed
@sobychacko
Copy link
Contributor

Thanks for the PR! Merged upstream.

sobychacko pushed a commit that referenced this pull request Dec 13, 2024
Fixes: #3660

Problem: consumeFromEmbeddedTopics calls Consumer.seekToEnd, which
"evaluates lazily, seeking to the final offset in all partitions only
when poll(Duration) or position(TopicPartition) are called".
This means that the consumer may or may not see future messages,
depending on timing.

This fix calls `position` so that the seek happens before
consumeFromEmbeddedTopics returns. That was it is ensured that any
message sent to the topic after the call to consumeFromEmbeddedTopics
are seen by the consumer.

Issue: #3660
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants