mercredi 8 mai 2019

Queued jobs occasionally repeating themselves Laravel Beanstalkd

Occasionally, if one job is stuck on the queue behind a long-running job, it seems to be picked up/attempted multiple times which is leading to repeat emails going out. I've reduced the size of each job and added multiple queues in order to speed jobs being dispatched up. I believe that I should add $job->delete() somewhere, but not sure where it should be.

I've created multiple queues and chunked up jobs being passed along in order to make sure that no processes are running too long or holding other processes up.

Here is what my *.conf file looks like (supervisord)

[program:lorem]
process_name=%(program_name)s_%(process_num)02d
command=php artisan queue:listen --queue=high,medium,low --sleep=30 --tries=1 --timeout=3600
directory=/var/www/html/lorem
autostart=true
autorestart=true
numprocs=6
redirect_stderr=true
stdout_logfile=/var/www/html/lorem/storage/logs/ipsum.log

and here is an example of where I dispatch a job to the queue:

    foreach ($users->chunk(100) as $chunkUser)
    {
        $job = (new InviteVendors($request, $chunkUser))->onQueue('high');
        app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($job);
    }


    $emailAgent = (new EmailAgentPostInvite($request))->onQueue('invitequeue');
    app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($emailAgent);

If I call $job->delete() after it is dispatched will it make sure that the job is not picked up multiple times? If not, where should I attempt to delete the job?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire