Ejemplo n.º 1
0
        public async Task Consume(ConsumeContext <CancelJob> context)
        {
            JobHandle jobHandle;

            if (!_roster.TryGetJob(context.Message.JobId, out jobHandle))
            {
                throw new JobNotFoundException($"The JobId {context.Message.JobId} was not found.");
            }

            await jobHandle.Cancel().ConfigureAwait(false);
        }
Ejemplo n.º 2
0
        public Task Consume(ConsumeContext <SuperviseJob> context)
        {
            JobHandle jobHandle;

            if (_roster.TryGetJob(context.Message.JobId, out jobHandle))
            {
                switch (jobHandle.Status)
                {
                case JobStatus.Created:
                case JobStatus.Running:
                    var timestamp = DateTime.UtcNow;

                    DateTime scheduledTime = timestamp + _checkInterval;

                    var supervise = new Supervise(context.Message.JobId, timestamp, JobStatus.Running);

                    context.ScheduleSend(scheduledTime, supervise);

                    if (_log.IsDebugEnabled)
                    {
                        _log.DebugFormat("Scheduled next supervise message: {0}", context.Message.JobId);
                    }
                    break;

                case JobStatus.RanToCompletion:
                    _roster.RemoveJob(context.Message.JobId);
                    break;

                case JobStatus.Faulted:
                    _roster.RemoveJob(context.Message.JobId);
                    break;

                case JobStatus.Canceled:
                    _roster.RemoveJob(context.Message.JobId);
                    break;
                }
            }
            else
            {
                if (_log.IsWarnEnabled)
                {
                    _log.WarnFormat("JobId not found: {0}", context.Message.JobId);
                }
            }

            return(TaskUtil.Completed);
        }