I did something wrong with my Beanstalkd setup. I have created a producer, but it keeps loading, like an infinite loop. I also posted this issue to GitHub.
I tried adding 2 tubes which have a simple array in them, but the other issue that I encounter is that when I used the name of the tube it doesn’t have the value I expect: it always gets the value on the old tube.
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require("vendor/autoload.php");
function p($s){
echo "<pre>";
print_r($s);
echo "</pre>";
}
use Pheanstalk\Pheanstalk;
$pheanstalk = new Pheanstalk('127.0.0.1'); //initiating an object
$watches = $pheanstalk->watch("ashimatube103613");
if ($pheanstalk->getConnection()->isServiceListening() == true) {
p($job = $pheanstalk->reserve());
while($job = $pheanstalk->reserve()) {
$getdata = $job->getData();
p($getdata);
echo 'test this is ';
$pheanstalk->delete($job);
}
}
$start = $pheanstalk->getConnection()->isServiceListening(); // true or false
echo $start."listening";
try {
# $job = $pheanstalk->reserve();
# p($job->getData());
echo 'here test';
} catch (Exception $e) {
echo "Error sending message - {$e->getMessage()} \n";
}
What have I done wrong?
Here is my producer code: producer.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
#echo phpinfo();
require("vendor/autoload.php");
function p($s){
echo "<pre>";
print_r($s);
echo "</pre>";
}
use Pheanstalk\Pheanstalk;
$pheanstalk = new Pheanstalk('127.0.0.1'); //initiating an object
$args = array(
"date" => "2017-1-17",
"id"=>array("7","8","39","4")
);
#producer
$put = $pheanstalk->useTube("ashimatube103613")->put(json_encode(array($args)));
exit();