private bool CheckTimestamp(EventMessageEntity entity) { long seconds = TimeUtil.CurrentTimestampSeconds() - entity.Timestamp; if (seconds <= _connectionSetting.AliveSeconds) { return(true); } _logger.LogCritical($"找到一个过期的EventMessage, Type : {entity.Type}, Timestamp:{entity.Timestamp}, Data:{entity.JsonData}"); return(false); }
protected override void TaskProcedure() { _logger.LogTrace($"ScanHistory Task Start, ThreadID:{Thread.CurrentThread.ManagedThreadId}"); try { while (true) { string[] redisKeys = new string[] { DistributedHistoryQueueName, DistributedConfirmIdHashName, DistributedQueueName }; string[] redisArgvs = new string[] { TimeUtil.CurrentTimestampSeconds().ToString(), _connectionSetting.WaitSecondsToBeAHistory.ToString() }; int result = _redis.ScriptEvaluate( redisInstanceName: _connectionSetting.RedisInstanceName, script: _popAndPushIfNotExistInHashScript, keys: redisKeys, argvs: redisArgvs); //TODO: add logs if (result == 1) { //时间太早,等会再检查 Thread.Sleep(10000); } else if (result == 2) { //成功 } else if (result == 3) { //重新放入队列再发送 } else { //出错 } } } catch (Exception ex) { _logger.LogCritical(ex, $"ScanHistory {_connectionSetting.BrokerName} 中,Thread Id : {Thread.CurrentThread.ManagedThreadId}, Exceptions: {ex.Message}"); } finally { //Thread.Sleep(); OnTaskFinished(); } }