Esempio n. 1
0
        protected internal static void invokeJobListener(CommandExecutor commandExecutor, JobFailureCollector jobFailureCollector)
        {
            if (!string.ReferenceEquals(jobFailureCollector.JobId, null))
            {
                if (jobFailureCollector.Failure != null)
                {
                    // the failed job listener is responsible for decrementing the retries and logging the exception to the DB.

                    FailedJobListener failedJobListener = createFailedJobListener(commandExecutor, jobFailureCollector.Failure, jobFailureCollector.JobId);

                    OptimisticLockingException exception = callFailedJobListenerWithRetries(commandExecutor, failedJobListener);
                    if (exception != null)
                    {
                        throw exception;
                    }
                }
                else
                {
                    SuccessfulJobListener successListener = createSuccessfulJobListener(commandExecutor);
                    commandExecutor.execute(successListener);
                }
            }
        }
Esempio n. 2
0
 public CommandAnonymousInnerClass(FailedJobListener outerInstance, CommandContext commandContext, Command <object> cmd)
 {
     this.outerInstance  = outerInstance;
     this.commandContext = commandContext;
     this.cmd            = cmd;
 }
Esempio n. 3
0
 /// <summary>
 /// Calls FailedJobListener, in case of OptimisticLockException retries configured amount of times.
 /// </summary>
 /// <returns> exception or null if succeeded </returns>
 private static OptimisticLockingException callFailedJobListenerWithRetries(CommandExecutor commandExecutor, FailedJobListener failedJobListener)
 {
     try
     {
         commandExecutor.execute(failedJobListener);
         return(null);
     }
     catch (OptimisticLockingException ex)
     {
         failedJobListener.incrementCountRetries();
         if (failedJobListener.RetriesLeft > 0)
         {
             return(callFailedJobListenerWithRetries(commandExecutor, failedJobListener));
         }
         return(ex);
     }
 }