Exemple #1
0
        public void HandleFailure(IOddJobWithMetadata jobWithMetadata, Exception exception)
        {
            if (jobWithMetadata.RetryParameters == null || jobWithMetadata.RetryParameters.MaxRetries <= jobWithMetadata.RetryParameters.RetryCount)
            {
                _jobQueueManager.MarkJobFailed(jobWithMetadata.JobId);

                try
                {
                    _jobStateExtension.OnJobFailed(jobWithMetadata);
                }
                catch (Exception ex)
                {
                    //TODO: better logging.
                }
            }
            else
            {
                _jobQueueManager.MarkJobInRetryAndIncrement(jobWithMetadata.JobId, DateTime.Now);
                try
                {
                    _jobStateExtension.OnJobRetry(jobWithMetadata);
                }
                catch (Exception ex)
                {
                    //TODO: Better logging;
                }
            }
        }
Exemple #2
0
 public void HandleSuccess(IOddJobWithMetadata jobWithMetadata)
 {
     _jobQueueManager.MarkJobSuccess(jobWithMetadata.JobId);
     try
     {
         _jobStateExtension.OnJobSuccess(jobWithMetadata);
     }
     catch (Exception e)
     {
         //TODO: Better Logging
     }
 }
        public IOddJobWithMetadata GetJob(Guid jobId)
        {
            IOddJobWithMetadata results = null;
            bool written = false;

            while (!written)
            {
                try
                {
                    using (FileStream fs =
                               File.Open(FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
                    {
                        byte[] toRead = null;
                        using (var memStream = new MemoryStream())
                        {
                            fs.CopyTo(memStream);
                            toRead = memStream.ToArray();
                        }
                        var serializer =
                            Newtonsoft.Json.JsonConvert.DeserializeObject <List <FileSystemJobMetaData> >(Encoding.UTF8.GetString(toRead), new JsonSerializerSettings()
                        {
                            TypeNameHandling = TypeNameHandling.All
                        });
                        var filtered = serializer.Where(q => q.JobId == jobId).FirstOrDefault();
                        written = true;
                        results = filtered;
                    }
                }
                catch (IOException ex)
                {
                    //Magic Number Source:
                    //https://stackoverflow.com/questions/2568875/how-to-tell-if-a-caught-ioexception-is-caused-by-the-file-being-used-by-another
                    if (ex.HResult == unchecked ((int)0x80070020))
                    {
                        //Retry.
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(results);
        }
Exemple #4
0
 public JobFailed(IOddJobWithMetadata jobData, Exception exception)
 {
     JobData   = jobData;
     Exception = exception;
 }
 /// <summary>
 /// Method to handle Missing Types on a Job.
 /// If a Job's type is missing, it will be marked in an error state (to prevent queue backup)
 /// But this method will let you specify a specific sort of warning/handler for the issue.
 /// </summary>
 /// <param name="job">The job missing a type.</param>
 protected virtual void OnJobTypeMissing(IOddJobWithMetadata job)
 {
 }
Exemple #6
0
 public virtual void OnJobRetry(IOddJobWithMetadata jobWithMetadata)
 {
 }
Exemple #7
0
 public virtual void OnJobSuccess(IOddJobWithMetadata jobWithMetadata)
 {
 }
Exemple #8
0
 public virtual void OnJobFailed(IOddJobWithMetadata jobWithMetadata)
 {
 }
Exemple #9
0
 public ExecuteJobRequest(IOddJobWithMetadata jobData)
 {
     JobData = jobData;
 }