/** * Delete a message from the Beanstalk queue. * * @param string $queue * @param string $id * @return void */ public function deleteMessage($queue, $id) { $this->pheanstalk->useTube($this->getQueue($queue))->delete($id); }
/** * Push a new job onto the queue after a delay. * * @param int $delay * @param string $job * @param mixed $data * @param string $queue * @return void */ public function later($delay, $job, $data = '', $queue = null) { $payload = $this->createPayload($job, $data); $pheanstalk = $this->pheanstalk->useTube($this->getQueue($queue)); $pheanstalk->put($payload, Pheanstalk::DEFAULT_PRIORITY, $delay); }
<?php /** * Created by JetBrains PhpStorm. * User: jcarmony * Date: 5/2/13 * Time: 12:10 AM * To change this template use File | Settings | File Templates. */ require_once '../vendor/autoload.php'; $beanstalk = new Pheanstalk_Pheanstalk('127.0.0.1'); $words = $argv; unset($words[0]); foreach ($words as $word) { $data = new stdClass(); $data->type = 'lookup_word'; $data->word = $word; $beanstalk->useTube('queue')->put(json_encode($data)); echo "Added {$word} \n"; } echo "Done!\n";
/** * Kick jobs * - server * - tube * - count : number of jobs to kick */ public function kickAction() { $server = $this->_getParam("server"); $tube = $this->_getParam("tube"); $count = $this->_getParam("count", 1); try { // Connect to the server $messageQueue = new Pheanstalk_Pheanstalk($server); $messageQueue->useTube($tube); $messageQueue->kick($count); $response = ""; } catch (Exception $e) { $this->getResponse()->setHttpResponseCode(500); $response = $e->getMessage(); } // Send Json response $this->jsonHelper->sendJson($response); $this->jsonHelper->getResponse()->sendResponse(); }
public function pushJob(JobPayloadInterface $jobPayload) { $this->pheanstalk->useTube($this->tube)->put(serialize($jobPayload)); }
/** * tells pheanstalk to use a certain tube * * @param $tube * @return $this */ public function useTube($tube) { $this->pheanstalk->useTube($tube); return $this; }