Affects: 2.3.7.RELEASE


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}]

I guess that if the PayloadMethodArgumentResolver already handled the payload argument it should not be activated again for another argument. Maybe add a boolean resolveOnlyOneArgument() method to the HandlerMethodArgumentResolver interface and use that method somehow in the HandlerMethodArgumentResolverComposite and the getMethodArgumentValues() method of InvocableHandlerMethod.

Removing the Acknowledment argument worked around the problem for me but for some scenarios it may be required and can't be removed

Comment From: rstoyanchev

What is supposed to resolve the Acknowledgement argument? The PayloadMethodArgumentResolver should typically be last in the order, or at least that's the way it is in Spring Framework infrastructure, and it shouldn't get in the way. This question might be more related to https://github.com/spring-projects/spring-kafka.

Comment From: selalerercapitolis

Opened in spring-kafka as suggested https://github.com/spring-projects/spring-kafka/issues/1683

Comment From: garyrussell

@rstoyanchev Status label can be changed to invalid - see my comment on the SK issue.

Comment From: snicoll

Thanks Gary. We have a dedicated label when the issue should be handled elsewhere in the first place. I just added it.