/// <summary>添加延迟消息</summary> /// <param name="value"></param> /// <param name="delay"></param> /// <returns></returns> public Int32 Add(T value, Int32 delay) { using var span = Redis.Tracer?.NewSpan($"redismq:AddDelay:{TraceName}", value); var rs = 0; for (var i = 0; i <= RetryTimesWhenSendFailed; i++) { // 添加到有序集合的成员数量,不包括已经存在更新分数的成员 rs = _sort.Add(value, DateTime.Now.ToInt() + delay); if (rs > 0) { return(rs); } span?.SetError(new RedisException($"发布到队列[{Topic}]失败!"), null); if (i < RetryTimesWhenSendFailed) { Thread.Sleep(RetryIntervalWhenSendFailed); } } ValidWhenSendFailed(span); return(rs); }
/// <summary>添加延迟消息</summary> /// <param name="value"></param> /// <param name="delay"></param> /// <returns></returns> public Int32 Add(T value, Int32 delay) { using var span = Redis.Tracer?.NewSpan($"redismq:AddDelay:{TraceName}", value); // 添加到有序集合的成员数量,不包括已经存在更新分数的成员 var rs = _sort.Add(value, DateTime.Now.ToInt() + delay); if (rs <= 0 && ThrowOnFailure) { var ex = new RedisException($"发布到队列[{Topic}]失败!"); span?.SetError(ex, null); throw ex; } return(rs); }
/// <summary>添加延迟消息</summary> /// <param name="value"></param> /// <param name="delay"></param> /// <returns></returns> public Int32 Add(T value, Int32 delay) { using var span = Redis.Tracer?.NewSpan($"redismq:AddDelay:{Key}", value); return(_sort.Add(value, DateTime.Now.ToInt() + delay)); }
/// <summary>添加延迟消息</summary> /// <param name="value"></param> /// <param name="delay"></param> /// <returns></returns> public Int32 Add(T value, Int32 delay) => _sort.Add(value, DateTime.Now.ToInt() + delay);