Ejemplo n.º 1
0
        protected internal static void HandleJobFailure(string nextJobId, JobFailureCollector jobFailureCollector,
                                                        System.Exception exception)
        {
            Log.ExceptionWhileExecutingJob(nextJobId, exception);

            jobFailureCollector.Failure = exception;
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
        public static void ExecuteJob(string jobId, ICommandExecutor commandExecutor)
        {
            var jobFailureCollector = new JobFailureCollector(jobId);

            ExecuteJob(jobId, commandExecutor, jobFailureCollector, new ExecuteJobsCmd(jobId, jobFailureCollector));
        }