예제 #1
0
파일: Queue.cs 프로젝트: vmaron/Roque
        /// <summary>
        /// Get the job that is currently marked as in progress for a worker.
        /// </summary>
        /// <param name="worker"></param>
        /// <returns>an in progress job, or null if none was found</returns>
        public Job GetInProgressJob(Worker worker)
        {
            try
            {
                RoqueTrace.Source.Trace(TraceEventType.Verbose, "Looking for pending jobs on {0} queue", Name);

                IQueueWithInProgressData queueWithInProgress = this as IQueueWithInProgressData;

                if (queueWithInProgress == null)
                {
                    // this queue doesn't support resuming work in progress
                    return(null);
                }
                string data = queueWithInProgress.GetInProgressJson(worker);
                if (string.IsNullOrEmpty(data))
                {
                    return(null);
                }
                Job job = JsonConvert.DeserializeObject <Job>(data);
                job.MarkAsResuming();

                RoqueTrace.Source.Trace(TraceEventType.Verbose, "Resuming pending job on {0} queue", Name);
                return(job);
            }
            catch (Exception ex)
            {
                RoqueTrace.Source.Trace(TraceEventType.Error, "Error receiving in progress job: {0}", ex.Message, ex);
                throw;
            }
        }
예제 #2
0
        /// <summary>
        /// Get the job that is currently marked as in progress for a worker.
        /// </summary>
        /// <param name="worker"></param>
        /// <returns>an in progress job, or null if none was found</returns>
        public Job GetInProgressJob(Worker worker)
        {
            try
            {
                if (RoqueTrace.Switch.TraceVerbose)
                {
                    Trace.TraceInformation(string.Format("Looking for pending jobs on {0}", Name));
                }

                IQueueWithInProgressData queueWithInProgress = this as IQueueWithInProgressData;

                if (queueWithInProgress == null)
                {
                    // this queue doesn't support resuming work in progress
                    return(null);
                }
                string data = queueWithInProgress.GetInProgressJson(worker);
                if (string.IsNullOrEmpty(data))
                {
                    return(null);
                }
                Job job = JsonConvert.DeserializeObject <Job>(data);
                job.MarkAsResuming();
                if (RoqueTrace.Switch.TraceVerbose)
                {
                    Trace.TraceInformation(string.Format("Resuming pending job on {0}", Name));
                }
                return(job);
            }
            catch (Exception ex)
            {
                if (RoqueTrace.Switch.TraceError)
                {
                    Trace.TraceError("Error dequeuing in progress job: " + ex.Message, ex);
                }
                throw;
            }
        }