Example #1
0
 /**
  * Обработка $this->_lastBatch и завершение текущей пачки.
  *
  * @overridden PGOConsumer::finish_batch()
  */
 protected function finish_batch($batch_id)
 {
     if ($this->_lastBatch) {
         $this->log->notice('Получен пакет (%d событий).', $this->_lastBatchSize);
         $sm = new pmail();
         $this->force_connect();
         foreach ($this->_lastBatch as $sender => $data) {
             // Рабочие значания $sender: BlogNewComment, CommuneNewComment.
             if (!$data) {
                 continue;
             }
             $this->log->notice('%s: %d сообщений на входе.', $sender, count($data));
             $this->log->notice('%s: %d писем обработано.', $sender, $sm->{$sender}($data, $this->pg_src_con));
         }
     }
     $this->_lastBatchSize = 0;
     $this->_lastBatch = null;
     return parent::finish_batch($batch_id);
 }
Example #2
0
 public function process()
 {
     //обязательный вызов для ротации логов
     $this->logRotate();
     parent::process();
 }
Example #3
0
 /**
  * ROLLBACK ongoing transactions on src & dst connections.
  */
 protected function rollback()
 {
     if ($this->pg_dst_con != null && $this->pg_dst_con !== false) {
         $this->log->notice("ROLLBACK pg_dst connection '%s'.", $this->dst_constr);
         pg_query($this->pg_dst_con, 'ROLLBACK;');
     }
     parent::rollback();
 }
Example #4
0
 public function process()
 {
     if (time() - $this->sleepTime > CHECK_INTERVAL) {
         $this->sleepTime = time();
         $this->DB->query("SELECT mail.task('work')");
     }
     parent::process();
 }