public async Task Consume(ConsumeContext <CancelJob> context) { if (!_registry.TryGetJob(context.Message.JobId, out var jobHandle)) { throw new JobNotFoundException($"The JobId {context.Message.JobId} was not found."); } LogContext.Debug?.Log("Cancelling job: {JobId}", jobHandle.JobId); await jobHandle.Cancel().ConfigureAwait(false); _registry.TryRemoveJob(jobHandle.JobId, out _); await jobHandle.NotifyCanceled("Job Service Stopped").ConfigureAwait(false); }
public async Task Consume(ConsumeContext <CancelJob> context) { JobHandle jobHandle; if (!_registry.TryGetJob(context.Message.JobId, out jobHandle)) { throw new JobNotFoundException($"The JobId {context.Message.JobId} was not found."); } if (_log.IsDebugEnabled) { _log.DebugFormat("Cancelling job: {0}", jobHandle.JobId); } await jobHandle.Cancel().ConfigureAwait(false); JobHandle removed; _registry.TryRemoveJob(jobHandle.JobId, out removed); await jobHandle.NotifyCanceled("Job Service Stopped").ConfigureAwait(false); }