public function setUp() { $dbh = getConnection(); $m = new \Queue\Manager(); $m->setPdo($dbh); $q = new \Queue\Queue('PHPUNIT', 5000); $q->setManager($m); $this->m = $m; $this->q = $q; }
public function testCreateQueueInstance() { $q = new \Queue\Queue('test'); $q->setManager($this->m); $queues = $this->m->getQueues(); $this->assertEquals(0, count($queues)); $m = new \QueueExample\Dummy(); $q->send($m); $msgs = $this->m->getTotalMessages(); $this->assertEquals(1, $msgs); $queues = $this->m->getQueues(); $this->assertEquals(1, count($queues)); }
/** * Need to override this method for facebook, since they use oauth2 * */ protected function send($pPostBody) { $this->onlineIdentity->scheduleImportJob(); Queue\Queue::getInstance()->put(new Documents\InterestImportJob($this->onlineIdentity->getId())); $lToken = $this->getAuthToken(); $pPostBody .= "&access_token=" . $lToken->getTokenKey(); return UrlUtils::sendPostRequest(sfConfig::get("app_" . $this->classToIdentifier() . "_post_api"), $pPostBody); }
public function executeWork(sfWebRequest $request) { $queue = Queue\Queue::getInstance(); while ($job = $queue->get()) { try { $job->execute(); $job->finished(); } catch (Exception $e) { $job->reschedule($e->getMessage()); } } return $this->redirect('job/index'); }
public function scheduleImportJob() { if (!$this->getLastFriendRefresh() || $this->getLastFriendRefresh() < strtotime(sfConfig::get("app_jobs_last_friend_refresh_threshold"))) { Queue\Queue::getInstance()->put(new Documents\ContactImportJob($this->getId())); } }
<?php /** * a batch file to send an email if a deal is expired * * @author Matthias Pfefferle */ require_once dirname(__FILE__) . '/../../config/BatchConfiguration.class.php'; require_once dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php'; $configuration = \ProjectConfiguration::getApplicationConfiguration('statistics', BatchConfiguration::ENV, true); \sfContext::createInstance($configuration); // get job $job = Queue\Queue::getInstance()->get(); if ($job) { try { // try to execute job $job->execute(); $job->finished(); } catch (\Exception $e) { $job->reschedule($e->getMessage()); } }