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

KafkaListener annotation for batch consumption does not work with Kotlin #699

Closed
zach-schoenberger opened this issue May 31, 2018 · 3 comments

Comments

@zach-schoenberger
Copy link
Contributor

zach-schoenberger commented May 31, 2018

https://github.com/spring-projects/spring-kafka/blob/master/spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/MessagingMessageListenerAdapter.java#L428

This does not work when using a kotlin function to consumer a batch list, as the parameter is not of ConsumerRecord.class. It is a WildcardTemplateImpl.class that exends ConsumerRecord.class

@artembilan
Copy link
Member

Would you mind to share some sample to reproduce?

We have this test class so far: https://github.com/spring-projects/spring-kafka/blob/master/spring-kafka/src/test/kotlin/org/springframework/kafka/listener/EnableKafkaKotlinTests.kt, but I agree that batch mode is not presented there.

Contribution at least with test-case is welcome!

Thanks

@zach-schoenberger
Copy link
Contributor Author

zach-schoenberger commented May 31, 2018

Sure, the sample code is to reproduce is simple if you have a cluster to consume from.
@KafkaListener(topics = ["topic"]) fun consumerRecords(consumerRecords: List<ConsumerRecord<String, String>>) { println(consumerRecords) }
What is actually passed to the function is a list of Strings instead of ConsumerRecord. From what you posted I don't think this would be covered, since the batch listener function is not actually invoked.

@zach-schoenberger
Copy link
Contributor Author

I have created a pr that adds a test case for this issue, and has a possible solution. if you run the test without the solution you will see the exceptions the bug causes and it will fail. #700

garyrussell added a commit that referenced this issue Jun 1, 2018
garyrussell pushed a commit that referenced this issue Jun 1, 2018
Fixes #699

showing issue with batch listener, along with fix

fixing checkstyle

fixing illegal import

GH-699: Fix line wrap
denis554 added a commit to denis554/spring-kafka that referenced this issue Mar 27, 2019
Fixes spring-projects/spring-kafka#699

showing issue with batch listener, along with fix

fixing checkstyle

fixing illegal import
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

No branches or pull requests

2 participants