/** * Returns the list of the jobs in queue for the server */ public function getListAction() { $server = $this->_getParam("server"); $data = array(); try { // Connect to the server and get job list $messageQueue = new Pheanstalk_Pheanstalk($server); $tubes = $messageQueue->listTubes(); foreach ($tubes as $tube) { $tubeArray = array(); // Next job ready try { /** @var Pheanstalk_Job $job */ $job = $messageQueue->peekReady($tube); $tubeArray[] = array('id' => $job->getId(), 'data' => $job->getData(), 'status' => 'ready'); } catch (Pheanstalk_Exception_ServerException $e) { // No job found } // Next job buried try { /** @var Pheanstalk_Job $job */ $job = $messageQueue->peekBuried($tube); $tubeArray[] = array('id' => $job->getId(), 'data' => $job->getData(), 'status' => 'buried'); } catch (Pheanstalk_Exception_ServerException $e) { // No job found } $data[$tube] = $tubeArray; } } catch (Pheanstalk_Exception_ConnectionException $e) { $this->getResponse()->setHttpResponseCode(400); $data = "Unable to connect to '{$server}'"; } catch (Exception $e) { $this->getResponse()->setHttpResponseCode(500); $data = $e->getMessage(); } // Send Json response $this->jsonHelper->sendJson($data); $this->jsonHelper->getResponse()->sendResponse(); }
/** * Return a list of queues/tubes on the queueing server * * @return array Array of Queues */ public function getQueues() { return $this->queue->listTubes(); }