예제 #1
0
 /**
  * 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);
 }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
<?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";
예제 #4
0
 /**
  * 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();
 }
예제 #5
0
 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;
 }