fix: 修复CAP幂等过滤时效过长导致重试参数行为操作过快而出现禁止处理问题,现将时效调整至1s

This commit is contained in:
云龙 王 2024-12-12 11:11:00 +08:00
parent 8105d04144
commit 1702aa7654

View File

@ -29,7 +29,7 @@ public class CapFilter : SubscribeFilter
context.DeliverMessage.Headers["sjzy-arguments-hash"] = hash;
}
if (await RedisHelper.Client.ExistsAsync($"CapExecuteFilter:{hash}"))
if (await RedisHelper.Client.ExistsAsync($"CapExecuteFilter:{hash}{DateTime.Now:G}"))
{
throw new BusinessException(GlobalConst.CapNoRetryErrorCode, $"检测到重复消费,消费参数:{argumentJsonStr}");
}
@ -41,7 +41,7 @@ public class CapFilter : SubscribeFilter
context.DeliverMessage.Headers.TryGetValue("sjzy-arguments-hash", out var hash);
if (!hash.IsNullOrEmpty())
{
await RedisHelper.Client.SetAsync($"CapExecuteFilter:{hash}", 1, TimeSpan.FromMinutes(3));
await RedisHelper.Client.SetAsync($"CapExecuteFilter:{hash}{DateTime.Now:G}", 1, TimeSpan.FromMinutes(3));
}
}