在gearman客户端,如何删除试图调用不存在的函数的作业?

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:

  1. Use the gearman CLI tool in worker mode to grab the jobs and send them to /dev/null:

gearman -n -w -f your_function_name > /dev/null

  1. Restart gearmand. Note that if you are using a persistent job store, you will need to delete the job records from the table. If you're not using a persistent job store, be careful - you will lose all other jobs as well.