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:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
garyrussellcommented, Jan 19, 2021

The MessagingMessageListenerAdapter already has a field hasAckParameter.

We currently only check it if a MessageConversionException is 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 MethodArgumentNotValidException to the catch.

0reactions
ExperienceCodeWarscommented, Feb 27, 2022

@garyrussell Thanks a lot. I’m sorry I wrote in the closed issues, in the future I will turn to the right discussions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Listener method could not be invoked with the incoming ...
1 Answer 1 · 1. required=false means the argument can be null . · One more thing do you have data, Like If...
Read more >
kafka问题之Listener method could not be invoked ... - CSDN博客
Acknowledgment ): 1 error(s): [Error in object 'ack': codes []; arguments []; default message [Payload value must not be empty]] ...
Read more >
org.springframework.messaging.handler.annotation.Payload
addError(new ObjectError(paramName, "Payload value must not be empty")); throw new MethodArgumentNotValidException(message, parameter, ...
Read more >
Message (SmallRye Reactive Messaging : API 3.7.1 API) - javadoc.io
A message contains a non- null payload, an acknowledgement function and a set of metadata. ... must not be null , must not...
Read more >
Spring for Apache Kafka
To send a null payload using the KafkaTemplate simply pass null into the value argument of the send() methods. One exception to this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found