/**
  * @see BaseJob::run()
  */
 public function run()
 {
     $autoresponderItemsToProcess = AutoresponderItem::getByProcessedAndProcessDateTime(AutoresponderItem::NOT_PROCESSED, time(), static::$pageSize);
     foreach ($autoresponderItemsToProcess as $autoresponderItem) {
         try {
             $this->processAutoresponderItemInQueue($autoresponderItem);
         } catch (NotFoundException $e) {
             return $autoresponderItem->delete();
         } catch (NotSupportedException $e) {
             $this->errorMessage = $e->getMessage();
             return false;
         }
     }
     return true;
 }
 /**
  * @see BaseJob::run()
  */
 public function run()
 {
     $batchSize = $this->resolveBatchSize();
     $autoresponderItemsToProcess = AutoresponderItem::getByProcessedAndProcessDateTime(0, time(), $batchSize);
     foreach ($autoresponderItemsToProcess as $autoresponderItem) {
         try {
             $this->processAutoresponderItemInQueue($autoresponderItem);
         } catch (NotFoundException $e) {
             return $autoresponderItem->delete();
         } catch (NotSupportedException $e) {
             $this->errorMessage = $e->getMessage();
             return false;
         }
     }
     return true;
 }
 protected function processRun()
 {
     $batchSize = $this->resolveBatchSize();
     $autoresponderItemsToProcess = AutoresponderItem::getByProcessedAndProcessDateTime(0, time(), $batchSize);
     $startingMemoryUsage = memory_get_usage();
     $modelsProcessedCount = 0;
     foreach ($autoresponderItemsToProcess as $autoresponderItem) {
         try {
             $this->processAutoresponderItemInQueue($autoresponderItem);
         } catch (NotFoundException $e) {
             return $autoresponderItem->delete();
         } catch (NotSupportedException $e) {
             $this->errorMessage = $e->getMessage();
             return false;
         }
         $this->runGarbageCollection($autoresponderItem);
         $modelsProcessedCount++;
     }
     $this->addMaxmimumProcessingCountMessage($modelsProcessedCount, $startingMemoryUsage);
     return true;
 }
 protected function processRun()
 {
     $batchSize = $this->resolveBatchSize();
     if ($batchSize != null) {
         $resolvedBatchSize = $batchSize + 1;
     } else {
         $resolvedBatchSize = null;
     }
     $autoresponderItemsToProcess = AutoresponderItem::getByProcessedAndProcessDateTime(0, time(), $resolvedBatchSize);
     $startingMemoryUsage = memory_get_usage();
     $modelsProcessedCount = 0;
     foreach ($autoresponderItemsToProcess as $autoresponderItem) {
         try {
             $this->processAutoresponderItemInQueue($autoresponderItem);
         } catch (NotFoundException $e) {
             return $autoresponderItem->delete();
         } catch (NotSupportedException $e) {
             $this->errorMessage = $e->getMessage();
             return false;
         }
         $this->runGarbageCollection($autoresponderItem);
         $modelsProcessedCount++;
         if ($this->hasReachedMaximumProcessingCount($modelsProcessedCount, $batchSize)) {
             Yii::app()->jobQueue->add('AutoresponderQueueMessagesInOutbox', 5);
             break;
         }
         if (!Yii::app()->performance->isMemoryUsageSafe()) {
             $this->addMaximumMemoryUsageReached();
             Yii::app()->jobQueue->add('AutoresponderQueueMessagesInOutbox', 5);
             break;
         }
     }
     $this->addMaxmimumProcessingCountMessage($modelsProcessedCount, $startingMemoryUsage);
     return true;
 }