/** * Adds job to query * * @param string $tube tube name * @param string $data data to worker * @param int|null $ttl time to execute this job * @param int $priority Jobs with smaller priority values will be scheduled * before jobs with larger priorities. The most urgent priority is 0; * the least urgent priority is 4294967295. * @param int $delay delay before insert job into work query * @return bool */ public function addJob($tube, $data, $ttl = null, $priority = 0, $delay = 0) { $ttl = $ttl ?: $this->defaultJobTtr; if ($tube != $this->_currTube) { $this->_client->useTube($tube); $this->_currTube = $tube; } return $this->_client->put($priority, $delay, $ttl, $data); }
#!/usr/bin/env php <?php use Beanstalk\Client as BeanstalkClient; require_once __DIR__ . '/../vendor/autoload.php'; $beanstalk = new BeanstalkClient(); $beanstalk->connect(); $beanstalk->useTube('Example3'); $i = 0; for ($i = 0; $i < 1; $i++) { $message = json_encode(array('id' => uniqid(md5(gethostname())), 'name' => 'Hello ' . $i)); $result = $beanstalk->put(500, 0, 60, $message); echo $message . "\n"; } $beanstalk->disconnect();