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

Batch and Acknowledgement are mutually exclusive #54

Closed
paulolieuthier opened this issue Jul 24, 2019 · 3 comments · Fixed by #887
Closed

Batch and Acknowledgement are mutually exclusive #54

paulolieuthier opened this issue Jul 24, 2019 · 3 comments · Fixed by #887
Assignees
Labels
status: pr submitted A pull request has been submitted for the issue type: improvement A minor improvement to an existing feature

Comments

@paulolieuthier
Copy link

Can't get batch and receive Acknowledgement at the same time.

Code sample:

@KafkaListener(groupId = "group-name", batch = true)
public class MessageKafkaConsumer {
    @Topic("topic-name")
    public void call(List<Message> message, Acknowledgement acknowledgement) {
        // ...
        acknowledgement.ack();
    }
}

Error message:

10:52:15.739 [pool-2-thread-1] ERROR i.m.c.k.e.KafkaListenerExceptionHandler - Kafka consumer [MessageKafkaConsumer@4e00663b] produced error: Required argument [Acknowledgement acknowledgement] not specified
io.micronaut.core.bind.exceptions.UnsatisfiedArgumentException: Required argument [Acknowledgement acknowledgement] not specified
	at io.micronaut.core.bind.DefaultExecutableBinder.bind(DefaultExecutableBinder.java:96)
	at io.micronaut.configuration.kafka.processor.KafkaConsumerProcessor.lambda$process$7(KafkaConsumerProcessor.java:421)
	at io.micrometer.core.instrument.composite.CompositeTimer.record(CompositeTimer.java:79)
	at io.micrometer.core.instrument.Timer.lambda$wrap$0(Timer.java:143)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

If I remove batch = true it works.

@paulolieuthier
Copy link
Author

Will be using org.apache.kafka.clients.consumer.Consumer and Consumer::commitSync() for now.

@hmatt1
Copy link
Contributor

hmatt1 commented Jul 29, 2019

@paulolieuthier
Copy link
Author

From the link:

Kafka does not support rejection of messages explicitly.

OK, but it supports manual committing. Acknowledgment works for that. Just not if consuming in batches.

sdelamo pushed a commit that referenced this issue Apr 24, 2023
* Add support for batch Acknowledgement.

* Remove use of Optional as method parameter.

* Fix checkStyle violation.
@guillermocalvo guillermocalvo self-assigned this Sep 29, 2023
@guillermocalvo guillermocalvo linked a pull request Oct 2, 2023 that will close this issue
@guillermocalvo guillermocalvo added status: pr submitted A pull request has been submitted for the issue type: improvement A minor improvement to an existing feature labels Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pr submitted A pull request has been submitted for the issue type: improvement A minor improvement to an existing feature
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants