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

AckCount is invalid when ackMode is Count and ackCount is less than maxPollRecords #2731

Closed
wapkch opened this issue Jul 6, 2023 · 5 comments · Fixed by #2858
Closed

AckCount is invalid when ackMode is Count and ackCount is less than maxPollRecords #2731

wapkch opened this issue Jul 6, 2023 · 5 comments · Fixed by #2858
Labels
ideal-for-user-contribution An issue that would ideal for a user to get started with contributing. type: enhancement

Comments

@wapkch
Copy link

wapkch commented Jul 6, 2023

Expected Behavior

Assume we have following settings:

application.properties

spring.kafka.listener.ack-mode=count
spring.kafka.listener.ack-count=100
logging.level.org.springframework.kafka=debug

Expect to commit offset every 100 messages processed

SpringBoot Application:

@RestController
@SpringBootApplication
public class SpringKafkaDemo2Application {

    public static void main(String[] args) {
        SpringApplication.run(SpringKafkaDemo2Application.class, args);
    }

    @KafkaListener(id = "fooGroup", topics = "topic")
    public void listen(ConsumerRecord<String, String> record) throws Exception {
    }

    @Autowired
    private KafkaTemplate<Object, Object> template;

    @PostMapping(path = "/send/{what}")
    public void sendFoo(@PathVariable String what) {
        for (int i = 0; i < 500; i++) {
            this.template.send("topic", "message" + i);
        }
    }

}

Current Behavior

Committing the offset every time after 500 records processed:

2023-07-06T18:07:36.680+08:00 DEBUG 26195 --- [ fooGroup-0-C-1] o.s.k.l.KafkaMessageListenerContainer    : Committing in COUNT because count 500 exceeds configured limit of 100
2023-07-06T18:07:36.680+08:00 DEBUG 26195 --- [ fooGroup-0-C-1] o.s.k.l.KafkaMessageListenerContainer    : Commit list: {topic-0=OffsetAndMetadata{offset=560, leaderEpoch=null, metadata=''}}
2023-07-06T18:07:36.680+08:00 DEBUG 26195 --- [ fooGroup-0-C-1] o.s.k.l.KafkaMessageListenerContainer    : Committing: {topic-0=OffsetAndMetadata{offset=560, leaderEpoch=null, metadata=''}}

Context
Although the larger the ackCount, the better the performance, but it will increase the chance of retransmission, so sometimes it is useful for the ackCount to be smaller than maxPollRecords

@wapkch wapkch changed the title Committing when ackCount exceeded if ackMode=Count and ackCount is less than maxPollRecords AckCount is invalid when ackMode=Count and ackCount is less than maxPollRecords Jul 6, 2023
@wapkch wapkch changed the title AckCount is invalid when ackMode=Count and ackCount is less than maxPollRecords AckCount is invalid when ackMode is Count and ackCount is less than maxPollRecords Jul 6, 2023
@garyrussell garyrussell added this to the Backlog milestone Jul 6, 2023
@garyrussell
Copy link
Contributor

We currently only consider count and time ack modes just before the next poll.

It's probably not a big change; I'll put it on the backlog.

Contributions are welcome.

@garyrussell garyrussell added the ideal-for-user-contribution An issue that would ideal for a user to get started with contributing. label Jul 6, 2023
@spring-projects spring-projects deleted a comment from Dharmik2510 Jul 11, 2023
@hscom96
Copy link

hscom96 commented Jul 21, 2023

@garyrussell Can i solve this issue?

@garyrussell
Copy link
Contributor

Yes, please go ahead. Please read the contribution guidelines.

@Wzy19930507
Copy link
Contributor

@hscom96 @garyrussell can I pick this up ?

@garyrussell
Copy link
Contributor

Yes, please do.

Wzy19930507 pushed a commit to Wzy19930507/spring-kafka that referenced this issue Oct 21, 2023
Wzy19930507 pushed a commit to Wzy19930507/spring-kafka that referenced this issue Oct 21, 2023
Wzy19930507 pushed a commit to Wzy19930507/spring-kafka that referenced this issue Oct 21, 2023
Wzy19930507 pushed a commit to Wzy19930507/spring-kafka that referenced this issue Oct 24, 2023
@garyrussell garyrussell modified the milestones: Backlog, 3.1.0 Oct 25, 2023
Wzy19930507 pushed a commit to Wzy19930507/spring-kafka that referenced this issue Oct 26, 2023
count ack mode commit offset when next poll return no records
garyrussell pushed a commit that referenced this issue Oct 30, 2023
* GH-2731: fix count and time ack mode

* GH-2731: fix count and time ack mode

count ack mode commit offset when next poll return no records

---------

Co-authored-by: Zhiyang.Wang1 <zhiyang.wang@caocaoglobal.com>
@garyrussell garyrussell removed this from the 3.1.0 milestone Oct 30, 2023
Wzy19930507 added a commit to Wzy19930507/spring-kafka that referenced this issue Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ideal-for-user-contribution An issue that would ideal for a user to get started with contributing. type: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants