Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Kafka使用者无法为JsonDeserializer使用905字节的消息_Java_Spring_Apache Kafka_Kafka Consumer Api_Spring Kafka - Fatal编程技术网

Java Kafka使用者无法为JsonDeserializer使用905字节的消息

Java Kafka使用者无法为JsonDeserializer使用905字节的消息,java,spring,apache-kafka,kafka-consumer-api,spring-kafka,Java,Spring,Apache Kafka,Kafka Consumer Api,Spring Kafka,我们正在与卡夫卡消费者和生产者一起使用Spring。我们正在生成大小为905字节的消息。我们正在序列化消息并尝试为下一个消费者反序列化它 消息有效负载类示例: { "FILE_LIST":[ { "KEY1": "Large String Value", "KEY2": "Large String Value", "Key3": "Large Strin

我们正在与卡夫卡消费者和生产者一起使用Spring。我们正在生成大小为905字节的消息。我们正在序列化消息并尝试为下一个消费者反序列化它

消息有效负载类示例:

{  
        "FILE_LIST":[  
            {
                "KEY1": "Large String Value",
                "KEY2": "Large String Value",
                "Key3": "Large String Value",
                "Key4": "Large String Value"
            }
        ]
}
有效载荷等级

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor
@AllArgsConstructor
public class InnerModel {

    @JsonProperty("KEY1")
    @Getter
    @Setter
    private String key1;

    @JsonProperty("KEY2")
    @Getter
    @Setter
    private String key2;

    @JsonProperty("KEY3")
    @Getter
    @Setter
    private String key3;

    @JsonProperty("KEY4")
    @Getter
    @Setter
    private String key4;
}
CustomModel.java

 package com.consumer.model; 


public class CustomModel {
    public CustomModel(List<InnerModel> filesList) {
        super();
        this.filesList = filesList;
    }

    @JsonProperty("FILE_LIST")
    @NonNull
    @Getter
    @Setter
    List<InnerModel> filesList;
}
应用程序属性

spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonDeserializer
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
spring.kafka.producer.compression-type=gzip 
spring.kafka.consumer.properties.spring.json.trusted.packages=com.consumer.model
当我们接受字符串格式的消息负载时,Consumer工作得很好,但当我们将Consumer中的负载反序列化为object时,我们面临着问题。下面的错误同样会引发

org.apache.kafka.common.errors.SerializationException:在偏移量70处反序列化分区customtopic-0的键/值时出错。如果需要,请通过记录继续消费。 原因:org.apache.kafka.common.errors.SerializationException:无法反序列化数据[[123, 34, 73, 78, 80, 85, 84, 95, 70, 73, 76, 69, 95, 76, 73, 83, 84, 34, 58, 91, 123, 34, 79, 82, 73, 71, 73, 78, 65, 76, 95, 67, 76, 73, 80, 95, 67, 85, 82, 82, 69, 78, 84, 34, 58, 34, 115, 51, 58, 47, 47, 98, 45, 97, 111, 45, 112, 114, 111, 100, 117, 99, 116, 45, 109, 111, 99, 107, 47, 55, 52, 49, 48, 57, 102, 98, 98, 45, 54, 102, 52, 101, 45, 52, 48, 54, 50, 45, 97, 98, 48, 102, 45, 100, 49, 102, 53, 98, 98, 102, 55, 49, 97, 56, 49, 47, 99, 108, 105, 112, 115, 47, 48, 58, 48, 48, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 51, 58, 48, 48, 46, 50, 48, 48, 47, 49, 48, 48, 48, 95, 111, 114, 105, 103, 105, 110, 97, 108, 99, 108, 105, 112, 47, 48, 58, 48, 48, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 51, 58, 48, 48, 46, 50, 48, 48, 47, 48, 58, 48, 48, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 51, 58, 48, 48, 46, 50, 48, 48, 47, 48, 58, 48, 48, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 51, 58, 48, 48, 46, 50, 48, 48, 46, 109, 112, 52, 34, 44, 34, 79, 82, 73, 71, 73, 78, 65, 76, 95, 67, 76, 73, 80, 95, 71, 76, 79, 66, 65, 76, 95, 84, 73, 77, 69, 83, 84, 65, 77, 80, 95, 67, 85, 82, 82, 69, 78, 84, 34, 58, 34, 115, 51, 58, 47, 47, 98, 45, 97, 111, 45, 112, 114, 111, 100, 117, 99, 116, 45, 109, 111, 99, 107, 47, 55, 52, 49, 48, 57, 102, 98, 98, 45, 54, 102, 52, 101, 45, 52, 48, 54, 50, 45, 97, 98, 48, 102, 45, 100, 49, 102, 53, 98, 98, 102, 55, 49, 97, 56, 49, 47, 99, 108, 105, 112, 115, 47, 48, 58, 48, 48, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 51, 58, 48, 48, 46, 50, 48, 48, 47, 49, 48, 48, 48, 95, 111, 114, 105, 103, 105, 110, 97, 108, 99, 108, 105, 112, 47, 48, 58, 48, 48, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 51, 58, 48, 48, 46, 50, 48, 48, 47, 48, 58, 48, 48, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 51, 58, 48, 48, 46, 50, 48, 48, 95, 116, 115, 47, 48, 58, 48, 48, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 51, 58, 48, 48, 46, 50, 48, 48, 95, 116, 115, 46, 106, 115, 111, 110, 34, 44, 34, 79, 82, 73, 71, 73, 78, 65, 76, 95, 67, 76, 73, 80, 95, 78, 69, 88, 84, 34, 58, 34, 115, 51, 58, 47, 47, 98, 45, 97, 111, 45, 112, 114, 111, 100, 117, 99, 116, 45, 109, 111, 99, 107, 47, 55, 52, 49, 48, 57, 102, 98, 98, 45, 54, 102, 52, 101, 45, 52, 48, 54, 50, 45, 97, 98, 48, 102, 45, 100, 49, 102, 53, 98, 98, 102, 55, 49, 97, 56, 49, 47, 99, 108, 105, 112, 115, 47, 48, 58, 48, 51, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 54, 58, 48, 48, 46, 50, 48, 48, 47, 49, 48, 48, 48, 95, 111, 114, 105, 103, 105, 110, 97, 108, 99, 108, 105, 112, 47, 48, 58, 48, 51, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 54, 58, 48, 48, 46, 50, 48, 48, 47, 48, 58, 48, 51, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 54, 58, 48, 48, 46, 50, 48, 48, 47, 48, 58, 48, 51, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 54, 58, 48, 48, 46, 50, 48, 48, 46, 109, 112, 52, 34, 44, 34, 79, 82, 73, 71, 73, 78, 65, 76, 95, 67, 76, 73, 80, 95, 71, 76, 79, 66, 65, 76, 95, 84, 73, 77, 69, 83, 84, 65, 77, 80, 95, 78, 69, 88, 84, 34, 58, 34, 115, 51, 58, 47, 47, 98, 45, 97, 111, 45, 112, 114, 111, 100, 117, 99, 116, 45, 109, 111, 99, 107, 47, 55, 52, 49, 48, 57, 102, 98, 98, 45, 54, 102, 52, 101, 45, 52, 48, 54, 50, 45, 97, 98, 48, 102, 45, 100, 49, 102, 53, 98, 98, 102, 55, 49, 97, 56, 49, 47, 99, 108, 105, 112, 115, 47, 48, 58, 48, 51, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 54, 58, 48, 48, 46, 50, 48, 48, 47, 49, 48, 48, 48, 95, 111, 114, 105, 103, 105, 110, 97, 108, 99, 108, 105, 112, 47, 48, 58, 48, 51, 58, 48, 48, 46, 48, 48, 48, 95, 48, 58, 48, 54, 58, 48,48,46,50,48,48,48,47,48,48,48,51,58,48,48,48,48,48,48,58,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,58,58,58,58,58,58,58,58,58,48,48,48,48,48,48,45,48,48,48,48,45,48,48,48,48,48,95,116,95,116,116,116,115,116,46,106,115,111,111,110,110,34,125,125,93,125]来自主题[customtopic]
原因:com.fasterxml.jackson.databind.exc.InvalidDefinitionException:无法构造
com.consumer.model.CustomModel
(不存在与默认构造类似的创建者):无法从对象值反序列化(无委托或基于属性的创建者) 在[源:(字节[])“{”文件列表“:[{”键1:“大字符串值”,“键2:“大字符串值”,“键3:“大字符串值”[截断的405字节];行:1,列:2] 在com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)~[jackson-databind-2.9.5.jar:2.9.5] 在com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1451)~[jackson-databind-2.9.5.jar:2.9.5] 在com.fasterxml.jackson.databind.DeserializationContext.HandleMissingInstallator(DeserializationContext.java:1027)~[jackson-databind-2.9.5.jar:2.9.5] 在com.fasterxml.jackson.databind.deser.BeandSerializedBase.DeserializeFromObjectUsingNodefault(BeandSerializedBase.java:1290)~[jackson-databind-2.9.5.jar:2.9.5] 在com.fasterxml.jackson.databind.deser.BeandSerializer.deserializeFromObject(BeandSerializer.java:326)~[jackson-databind-2.9.5.jar:2.9.5] 在com.fasterxml.jackson.databind.desr.BeanDeserializer.deseriali
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonDeserializer
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
spring.kafka.producer.compression-type=gzip 
spring.kafka.consumer.properties.spring.json.trusted.packages=com.consumer.model
package com.consumer.model; 

@NoArgsConstructor
@AllArgsConstructor
public class CustomModel {   
  @JsonProperty("FILE_LIST")
  @NonNull
  @Getter
  @Setter
  List<InnerModel> filesList;
}