Payload value must not be empty for Acknowledgment parameter
See original GitHub issue**Affects Version(s):2.6.5
Copying from https://github.com/spring-projects/spring-framework/issues/26389 since it seems this is right place for it.
I have a @KafkaListener with this signature:
@KafkaListener(topics = "${matcher.reply.channel:matcher_response${matcher.kafka.topic.suffix}}")
public void processMessage(@Payload ConsumerRecord<String, String> record, Acknowledgment acknowledgment) {
When I receive a message I get an exception that Payload value must not be empty about the acknowledgment parameter:
[org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1] SeekToCurrentErrorHandler - Backoff none exhausted for ConsumerRecord(topic = multilateral_matcher_results, partition = 0, leaderEpoch = 0, offset = 2, CreateTime = 1610624163545, serialized key size = -1, serialized value size = 76, headers = RecordHeaders(headers = [], isReadOnly = false), key = null, value = {"matchProcessId":"dc033ece-4e0e-4a60-86ce-7f8071678418","status":"SUCCESS"})
org.springframework.kafka.listener.ListenerExecutionFailedException: Listener method could not be invoked with the incoming message
Endpoint handler details:
Method [public void com.capitolis.matcher_client.kafka.consumer.MatcherReplyKafkaConsumer.processMessage(org.apache.kafka.clients.consumer.ConsumerRecord<java.lang.String, java.lang.String>,org.springframework.kafka.support.Acknowledgment)]
Bean [com.capitolis.matcher_client.kafka.consumer.MatcherReplyKafkaConsumer@193f5509]; nested exception is org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException: Could not resolve method parameter at index 1 in public void com.capitolis.matcher_client.kafka.consumer.MatcherReplyKafkaConsumer.processMessage(org.apache.kafka.clients.consumer.ConsumerRecord<java.lang.String, java.lang.String>,org.springframework.kafka.support.Acknowledgment): 1 error(s): [Error in object 'acknowledgment': codes []; arguments []; default message [Payload value must not be empty]] , failedMessage=GenericMessage [payload=org.springframework.kafka.support.KafkaNull@437ffb4f, headers={id=99763706-5013-dcae-a45a-16485a65854e, timestamp=1610624118214}]; nested exception is org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException: Could not resolve method parameter at index 1 in public void com.capitolis.matcher_client.kafka.consumer.MatcherReplyKafkaConsumer.processMessage(org.apache.kafka.clients.consumer.ConsumerRecord<java.lang.String, java.lang.String>,org.springframework.kafka.support.Acknowledgment): 1 error(s): [Error in object 'acknowledgment': codes []; arguments []; default message [Payload value must not be empty]] , failedMessage=GenericMessage [payload=org.springframework.kafka.support.KafkaNull@437ffb4f, headers={id=99763706-5013-dcae-a45a-16485a65854e, timestamp=1610624118214}]
It seems that the PayloadMethodArgumentResolver (or the KafkaNullAwarePayloadArgumentResolver that inherits from it) handles an argument that it shouldn’t. I thought it might be a compatibility issue and aligned my dependencies with the matrix here: https://spring.io/projects/spring-kafka But that did not prevent the exception.
Removing the Acknowledgement argument worked around the problem for me but for some scenarios it may be required and can’t be removed
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Related StackOverflow Question
The
MessagingMessageListenerAdapteralready has a fieldhasAckParameter.We currently only check it if a
MessageConversionExceptionis thrown.https://github.com/spring-projects/spring-kafka/blob/f9bc4195110c07651e004fa9ab9638d392c2baaa/spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/MessagingMessageListenerAdapter.java#L333-L339
We should change that to add a
MethodArgumentNotValidExceptionto the catch.@garyrussell Thanks a lot. I’m sorry I wrote in the closed issues, in the future I will turn to the right discussions.