7

ここで1つの問題が発生しています。サンプルがそれを物語っています。

Queue::after(function (JobProcessed $event) {
$job_details = json_decode($event->job->getRawBody(), true);

)});

$job_details は次のようになります。

'displayName' => 'App\\Jobs\\CommandJob',
  'job' => 'Illuminate\\Queue\\CallQueuedHandler@call',
  'maxTries' => 10,
  'timeout' => NULL,
  'data' => 
  array (
    'commandName' => 'App\\Jobs\\CommandJob',
    'command' => 'O:19:"App\\Jobs\\CommandJob":9:{s:32:"' . "\0" . 'App\\Jobs\\CommandJob' . "\0" . 'commandName";N;s:30:"' . "\0" . 'App\\Jobs\\CommandJob' . "\0" . 'arguments";N;s:28:"' . "\0" . 'App\\Jobs\\CommandJob' . "\0" . 'command";s:20:"google:get-campaigns";s:5:"tries";i:10;s:32:"' . "\0" . 'App\\Jobs\\CommandJob' . "\0" . 'nextCommand";a:1:{i:0;s:19:"google:get-adgroups";}s:6:"' . "\0" . '*' . "\0" . 'job";N;s:10:"connection";N;s:5:"queue";s:11:"update_data";s:5:"delay";N;}',

$job_details['data']['command'] からいくつかのパラメーターを取得したいと思います。これを行う簡単な方法はありますか、それとも自家製の魂が必要ですか?

4

3 に答える 3

0

I was having error with an email that contained some space in it, so I have to decode the payload of the failed jobs and update it.

In php artisan tinker,

// take some specific failed jobs
$failed_job = DB::table('failed_jobs')->where('id', $your_job_id)->first();
$payload = json_decode($failed_job->payload);
$obj = unserialize($payload->data->command);

   
// here I have the user content, I can see the wrong email
$user = $obj->notifiables; 
    
//update email and save
$user->email = "newemail@something"
$user->update()

As the last step, push again the jobs into the queue.

于 2021-12-04T09:15:12.083 に答える