private async Task <bool> DoWork(FetchJobData fetchJobData) { MessageResult messageResult = new MessageResult { Data = fetchJobData.Data, Topic = fetchJobData.Topic, JobId = fetchJobData.JobId }; var isSuccess = true; try { var task = OnMessage(messageResult); await task.TimeoutAfter(TimeSpan.FromSeconds(_options.ExecuteTimeoutSecond)); } catch (TimeoutException ex) //超时 { _logger.LogWarning(ex, $"redis消费超时,topic:{fetchJobData.Topic}"); isSuccess = true;//超时不重试 } catch (Exception ex) { _logger.LogError(ex, $"redis消费失败,topic:{fetchJobData.Topic}"); if (_options.IsRetry != null) { var isRetry = await _options.IsRetry(ex); isSuccess = !isRetry; } } return(isSuccess); }