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; } } }
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); }
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) { }
public virtual void OnJobRetry(IOddJobWithMetadata jobWithMetadata) { }
public virtual void OnJobSuccess(IOddJobWithMetadata jobWithMetadata) { }
public virtual void OnJobFailed(IOddJobWithMetadata jobWithMetadata) { }
public ExecuteJobRequest(IOddJobWithMetadata jobData) { JobData = jobData; }