zoukankan      html  css  js  c++  java
  • org.apache.kafka.common.errors.SerializationException: Error deserializing... Caused by: org.apache.kafka.common.errors.SerializationException: Size of data received by IntegerDeserializer is not 4

    原因,最近开发的kafka消息接收,突然报如下错:

    org.apache.kafka.common.errors.SerializationException: Error deserializing... Caused by: org.apache.kafka.common.errors.SerializationException: Size of data received by IntegerDeserializer is not 4

    原因如下,我的kafka序列化配置中配置的序列化类如下:

    key.deserializer=org.apache.kafka.common.serialization.IntegerDeserializer
    value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
    IntegerDeserializer源码如下:
    public Integer deserialize(String topic, byte[] data) {
            if (data == null) {
                return null;
            } else if (data.length != 4) {
                throw new SerializationException("Size of data received by IntegerDeserializer is not 4");
            } else {
                int value = 0;
                byte[] arr$ = data;
                int len$ = data.length;
    
                for(int i$ = 0; i$ < len$; ++i$) {
                    byte b = arr$[i$];
                    value <<= 8;
                    value |= b & 255;
                }
    
                return value;
            }
        }

    解决方法,将配置做如下修改:

    key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
    value.deserializer=org.apache.kafka.common.serialization.StringDeserializer

    问题解决。

     
  • 相关阅读:
    SimpleDateFormatter Java中的用法
    线性判别分析浅析及推导
    主成分分析(PCA)原理及推导
    浅说机器学习理论
    给“过拟合”下一个准确且规范的定义
    信息熵和Gini指数的关系
    WinRAR默认压缩格式ZIP
    批量学习和在线学习的区别
    LDA线性判别分析
    主成分分析(PCA)原理与实现
  • 原文地址:https://www.cnblogs.com/jxxblogs/p/13272600.html
Copyright © 2011-2022 走看看