I'm using the Gearman php API.
In my client side, gclient.php:
$gClient = new GearmanClient();
$gClient->addServer('127.0.0.1', 4730);
$gClient->setTimeout(2000);
$ret = $gClient->doNormal('functionNameNonexist', json_encode(array(
'k' => 'v',
)));
$returnCode = $gClient->returnCode();
if ($returnCode != GEARMAN_SUCCESS)
{
echo "bad return code: {$returnCode}
";
}
By running the command gearadmin --show-jobs
, I can see the jobs queue became longer after each time the php script is executed.
Is there a way to remove/cancel those jobs that have been stayed in the queue over like 1 minute.
There is two fast ways to remove jobs in the queue:
gearman -n -w -f your_function_name > /dev/null