redis subscribe 连接中断

Exception in thread "Thread-12" redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Software caused connection abort: recv failed
    at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:202)
    at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40)
    at redis.clients.jedis.Protocol.process(Protocol.java:147)
    at redis.clients.jedis.Protocol.read(Protocol.java:211)
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
    at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:242)
    at redis.clients.jedis.JedisPubSub.process(JedisPubSub.java:121)
    at redis.clients.jedis.JedisPubSub.proceed(JedisPubSub.java:115)
    at redis.clients.jedis.Jedis.subscribe(Jedis.java:2628)
    at redis.clients.jedis.JedisCluster$150.execute(JedisCluster.java:1624)
    at redis.clients.jedis.JedisCluster$150.execute(JedisCluster.java:1621)
    at redis.clients.jedis.JedisClusterCommand.runWithAnyNode(JedisClusterCommand.java:88)
    at redis.clients.jedis.JedisCluster.subscribe(JedisCluster.java:1627)
    at com.dominos.cloud.pe.utils.RuleDataSource$1.run(RuleDataSource.java:87)
Caused by: java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:196)
    ... 13 more

 

场景:

redis subscribe ,网络中断,连接中断后,报此异常,然后不能继续吊费。

public void subscribeRuleChannel() {
		redisManager.getJedisCluster().subscribe(new JedisPubSub() {
			@Override
		    public void onMessage(String channel, String message) {       //收到消息会调用
		        System.out.println(String.format("收到消息成功! channel: %s, message: %s", channel, message));
		       // this.unsubscribe();
				//清空本地缓存
				
		    }
		    @Override
		    public void onSubscribe(String channel, int subscribedChannels) {    //订阅频道会调用
		        System.out.println(String.format("订阅频道成功! channel: %s, subscribedChannels %d",
		        channel, subscribedChannels));
		    }
		 
		    @Override
		    public void onUnsubscribe(String channel, int subscribedChannels) {   //取消订阅会调用
		        System.out.println(String.format("取消订阅频道! channel: %s, subscribedChannels: %d",
		                channel, subscribedChannels));
		    }
			
		}, RULE_CHANNEL);
	}

 

转载于:https://my.oschina.net/xiaominmin/blog/2995064

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值