/**
  * Process all pending tasks
  */
 public function work()
 {
     while (count($task = $this->_queue->receive()) > 0) {
         try {
             $taskData = $task->toArray();
             $this->getWorker()->execute($taskData[0]);
         } catch (Exception $e) {
             $this->_logger->logException($e);
         }
     }
 }
示例#2
0
 /**
  * Log information about exception to exception log.
  *
  * @param Exception $exception
  * @return string $reportId
  */
 protected function _logException(Exception $exception)
 {
     $exceptionClass = get_class($exception);
     $reportId = uniqid("webapi-");
     $exceptionForLog = new $exceptionClass("Report ID: {$reportId}; Message: {$exception->getMessage()}", $exception->getCode());
     $this->_logger->logException($exceptionForLog);
     return $reportId;
 }
 /**
  * Initialize and execute changelog clear action with metadata provided.
  *
  * @param Enterprise_Mview_Model_Metadata $metadata
  */
 protected function _runCleanupAction(Enterprise_Mview_Model_Metadata $metadata)
 {
     $this->_getClient()->init($metadata->getTableName());
     try {
         $this->_getClient()->execute('enterprise_mview/action_changelog_clear');
     } catch (Exception $e) {
         $this->_logger->logException($e);
     }
 }
示例#4
0
 /**
  * Delete a message from the queue
  *
  * @param Zend_Queue_Message $message
  * @return bool
  */
 public function deleteMessage(Zend_Queue_Message $message)
 {
     try {
         $msg = $this->_queueTaskModel->load($message->handle, 'handle');
         if (!is_null($msg->getId())) {
             $msg->delete();
             return true;
         }
     } catch (Exception $e) {
         $this->_logger->logException($e);
     }
     return false;
 }
示例#5
0
 /**
  * Execute specified task
  *
  * @param array $task
  * @return bool
  */
 public function execute($task)
 {
     $taskDetails = Zend_Json::decode($task['data']);
     if (isset($taskDetails['task_name'])) {
         try {
             $this->_config->loadEventObservers('workers');
             $this->_app->addEventArea('workers');
             $this->getReporter()->reportTaskProcessing($task['task_id']);
             $this->_dispatchEvent($taskDetails['task_name'], $taskDetails['params']);
             $this->getReporter()->reportTaskCompleted($task['task_id']);
         } catch (Exception $e) {
             $this->getReporter()->reportTaskFailed($task['task_id']);
             $this->_logger->logException($e);
         }
     }
     return true;
 }
示例#6
0
 /**
  * Build menu model from config
  *
  * @return Mage_Backend_Model_Menu
  * @throws InvalidArgumentException|BadMethodCallException|OutOfRangeException|Exception
  */
 public function getMenu()
 {
     $store = $this->_factory->get('Mage_Core_Model_App')->getStore();
     $this->_logger->addStoreLog(Mage_Backend_Model_Menu::LOGGER_KEY, $store);
     try {
         $this->_initMenu();
         return $this->_menu;
     } catch (InvalidArgumentException $e) {
         $this->_logger->logException($e);
         throw $e;
     } catch (BadMethodCallException $e) {
         $this->_logger->logException($e);
         throw $e;
     } catch (OutOfRangeException $e) {
         $this->_logger->logException($e);
         throw $e;
     } catch (Exception $e) {
         throw $e;
     }
 }