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

    问题解决。

     
  • 相关阅读:
    .NET Cache缓存
    异步
    es6常用功能
    vue-router路由懒加载
    vue中nextTick和$nextTick
    动态模板中 swiper 划不动问题
    javaScript正则判断手机号
    Mac终端使用技巧
    alert IOS自带域名
    vue css background路径不对
  • 原文地址:https://www.cnblogs.com/jxxblogs/p/13272600.html
Copyright © 2011-2022 走看看