提交 05a65721 编写于 作者: L lpphan 提交者: 晴天丶en

修改问题

上级 0a5fdf63
......@@ -16,9 +16,9 @@ import org.springframework.data.redis.listener.RedisMessageListenerContainer;
public class RedisListenerConfig {
@Bean
@Primary
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory) {
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory factory) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setConnectionFactory(factory);
return container;
}
}
......@@ -54,9 +54,10 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
}
String accessValue = expiredKey.substring(expiredKey.indexOf(":") + 1);
// 分布式集群部署下防止一个过期被多个服务重复消费
String qc = redisRepository.getAndSet("qc:" + accessValue, "1");
if (StringUtils.isNotEmpty(qc) && "1".equals(qc)) {
log.debug("其他节点已经处理了该数据,次数跳过");
String qc = "qc:" + accessValue;
String oldLock = redisRepository.getAndSet(qc, "1");
if (StringUtils.isNotEmpty(oldLock) && "1".equals(oldLock)) {
log.debug("其他节点已经处理了该数据,跳过");
return;
}
byte[] accessBakKey = serializeKey(SecurityConstants.ACCESS_BAK + accessValue);
......@@ -77,7 +78,7 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
} catch (Exception e) {
log.error(e.getMessage());
} finally {
conn.del();
conn.del(oldLock.getBytes());
conn.close();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册