protected internal static void HandleJobFailure(string nextJobId, JobFailureCollector jobFailureCollector, System.Exception exception) { Log.ExceptionWhileExecutingJob(nextJobId, exception); jobFailureCollector.Failure = exception; }
public virtual ProcessEngineException WrapJobExecutionFailure(JobFailureCollector jobFailureCollector, System.Exception cause) { var job = jobFailureCollector.Job; if (job != null) { return (new ProcessEngineException( ExceptionMessage("025", "Exception while executing job {0}: ", jobFailureCollector.JobId), cause)); } return (new ProcessEngineException( ExceptionMessage("025", "Exception while executing job {0}: ", jobFailureCollector.JobId), cause)); }
public static void ExecuteJob(string nextJobId, ICommandExecutor commandExecutor, JobFailureCollector jobFailureCollector, ICommand <object> cmd) { try { commandExecutor.Execute(cmd); } catch (ProcessEngineException exception) { HandleJobFailure(nextJobId, jobFailureCollector, exception); throw; } catch (System.Exception exception) { HandleJobFailure(nextJobId, jobFailureCollector, exception); // wrap the exception and throw it to indicate the ExecuteJobCmd failed throw Log.WrapJobExecutionFailure(jobFailureCollector, exception); } finally { InvokeJobListener(commandExecutor, jobFailureCollector); } }
protected internal static void InvokeJobListener(ICommandExecutor commandExecutor, JobFailureCollector jobFailureCollector) { if (!string.IsNullOrEmpty((jobFailureCollector.jobId))) { if (jobFailureCollector.Failure != null) { // the failed job listener is responsible for decrementing the retries and logging the exception to the DB. var failedJobListener = CreateFailedJobListener(commandExecutor, jobFailureCollector.Failure, jobFailureCollector.JobId); OptimisticLockingException exception = CallFailedJobListenerWithRetries(commandExecutor, failedJobListener); if (exception != null) { throw exception; } } else { var successListener = CreateSuccessfulJobListener(commandExecutor); commandExecutor.Execute(successListener); } } }
public static void ExecuteJob(string jobId, ICommandExecutor commandExecutor) { var jobFailureCollector = new JobFailureCollector(jobId); ExecuteJob(jobId, commandExecutor, jobFailureCollector, new ExecuteJobsCmd(jobId, jobFailureCollector)); }