page contents

redission 监听key过期事件异常

Pack 发布于 2020-01-06 16:27
阅读 2837
收藏 0
分类:nosql缓存

redission 监听key过期事件异常

问题描述

redission 监听key过期事件异常


问题出现的环境背景及自己尝试过哪些方法

采用redis客户端手动监听 SUBSCRIBE keyevent@0:expired ,key过期事件监听成功

redission 监听Redis普通发布订阅消息成功

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

RTopic topic = redisson.getTopic(“keyevent@0:expired”,new SerializationCodec());

topic.addListener(String.class, new MessageListener() {

@Override

public void onMessage(CharSequence charSequence, String s) {

System.out.println(“onMessage:”+charSequence+"; Thread: "+Thread.currentThread().toString());

System.out.println(s);

}

});


你期待的结果是什么?实际看到的错误信息又是什么?

期待结果:通过监听器获取订单未支付取消的key,回滚库存

错误信息:ERROR 62868 — [isson-netty-2-7] o.r.client.handler.CommandPubSubDecoder : Unable to decode data. channel: [id: 0x3c4787b6, L:/127.0.0.1:60779 - R:redis.mall.com/127.0.0.1:6379], reply: ReplayingDecoderByteBuf(ridx=54, widx=54)


java.io.EOFException: null

at java.io.ObjectInputStreamPeekInputStream.readFully(ObjectInputStream.java:2681) ~[na:1.8.0_231] at java.io.ObjectInputStreamPeekInputStream.readFully(ObjectInputStream.java:2681) [na:1.8.0 

2

​ 31]atjava.io.ObjectInputStreamBlockDataInputStream.readShort(ObjectInputStream.java:3156) ~[na:1.8.0_231]

at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:863) ~[na:1.8.0_231]

at java.io.ObjectInputStream.(ObjectInputStream.java:358) ~[na:1.8.0_231]

at org.redisson.codec.SerializationCodec$1.decode(SerializationCodec.java:53) ~[redisson-3.11.1.jar:3.11.1]

at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:384) [redisson-3.11.1.jar:3.11.1]

at org.redisson.client.handler.CommandDecoder.decodeList(CommandDecoder.java:428) [redisson-3.11.1.jar:3.11.1]

at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:393) [redisson-3.11.1.jar:3.11.1]

at org.redisson.client.handler.CommandPubSubDecoder.decodeCommand(CommandPubSubDecoder.java:76) ~[redisson-3.11.1.jar:3.11.1]


113
Pack
Pack

你这一步在哪里操作空指针,是接收过期推动消息还是接收到后,处理业务空指针?你这里报Unable to decode data. channel: [id: 0x3c4787b6, L:/127.0.0.1:60779 - R:redis.mall.com/127.0.0.1:6379], reply: 你看你的数据跟他的数据格式是不是不一致,应该是这个attachments-2020-01-eaRh5NyH5e12ef9da3f5b.png你这种没用过,用过其他几种,没遇到这种问题

请先 登录 后评论