You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On kotlin application, Spring kafka 3.2.0 doesn't take the message conversion logic, because of the wrong coroutine detection on MessagingMessageListenerAdapter
#3277
Closed
huisam opened this issue
May 24, 2024
· 2 comments
because on kotlin, @KafkaListener method parameter type is always kotlin type. So the conversionNeeded flag changes to false.
This occurs messageConverters not working normally.
consumes normally and execute the execute() method but it occurs MethodArgumentNotValidException exception
org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException: Could not resolve method parameter at index 0 in public void com.company.test.spring.kafka.TestKafkaService.onMessage(com.company.test.spring.kafka.TestMessage): 1 error(s): [Error in object 'message': codes []; arguments []; default message [Payload value must not be empty]]
Sample
sample is on the issue
The text was updated successfully, but these errors were encountered:
huisam
changed the title
Spring kafka 3.2.0 doesn't take the message conversion logic, because of the wrong coroutine detection on MessagingMessageListenerAdapter
On kotlin application, Spring kafka 3.2.0 doesn't take the message conversion logic, because of the wrong coroutine detection on MessagingMessageListenerAdapter
May 24, 2024
Looks like we have overseen this scenario when we tested Kotlin support for @KafkaListener:
@KafkaListener(id = "kotlin", topics = ["kotlinTestTopic1"], containerFactory = "kafkaListenerContainerFactory")
fun listen(value: String) {
this.received = value
this.latch1.countDown()
}
That String is indeed not a Kotlin type 😄 .
Feel free to contribute the fix as you have just explained.
And I guess with respective fix for that EnableKafkaKotlinTests.test listener() test and its configuration with the mentioned listen() method.
…apter
Fixes: #3277
* Fix coroutine detection logic in `MessagingMessageListenerAdapter` by continuation class type
* Use proper `@since 3.2.1` for new API
(cherry picked from commit abaa465)
In what version(s) of Spring for Apache Kafka are you seeing this issue?
For example:
3.2.0
Between 3.1.4 and 3.2.0
Describe the bug
On the MessagingMessageListenerAdapter class there is a bug on the
determineInferredType
method.if you determine the coroutine function, you should have to use
not
isKotlinType
methodbecause on kotlin,
@KafkaListener
method parameter type is always kotlin type. So theconversionNeeded
flag changes to false.This occurs messageConverters not working normally.
To Reproduce
Expected behavior
consumes normally and execute the
execute()
method but it occursMethodArgumentNotValidException
exceptionSample
sample is on the issue
The text was updated successfully, but these errors were encountered: