Laravel Queue Driver not calling handle() on jobs, but queue:listen daemon is logging jobs as processed
Asked Answered
R

1

11

I've taken over a Laravel 5.2 project where handle() was being called successfully with the sync queue driver.

I need a driver that supports dispatch(..)->delay(..) and have attempted to configure both database and beanstalkd, with numerous variations, unsuccessfully - handle() is no longer getting called.

Current setup

I am using Forge for server management and have set up a daemon, which is automatically kept running by Supervisor, for this command:

php /home/forge/my.domain.com/envoyer/current/artisan queue:listen --sleep=3 --tries=3

I've also tried queue:work, naming 'database/beanstalkd', with and without specifying --sleep, --tries , --deamon

I have an active beanstalkd worker running on forge.

I have set the default driver to beanstalkd in \config\queue.php and QUEUE_DRIVER=beanstalkd in my .env from within Envoyer, which has worked fine for other environment variables.

After build deployment Envoyer runs the following commands successfully:

php artisan config:clear
php artisan migrate
php artisan cache:clear
php artisan queue:restart

Debug information

My queue:listen daemon produces log within .forge says it processed a job!

[2017-07-04 08:59:13] Processed: App\Jobs\GenerateRailwayReport

Where that job class is defined like this:

class GenerateRailwayReport extends Job implements ShouldQueue
{
    use InteractsWithQueue, SerializesModels;
    protected $task_id;

    public function __construct($task_id)
    {
        $this->task_id = $task_id;
        clock("GenerateRailwayReport constructed"); // Logs Fine
    }

    public function handle()
    {
        clock("Handling Generation of railway report"); // Never Logs
        //Bunch of stuff all commented out during my testing
    }

    public function failed(Exception $e)
    {
        clock("Task failed with exception:"); // Never Logs
        clock($e);
    }
}

My beanstalkd worker log within .forge has no output in it.

Nothing in my failed_jobs table.

-Really, really appreciate any help at this point!

Retinite answered 4/7, 2017 at 11:44 Comment(4)
Post your handle method code.Stanwinn
@Stanwinn - Posted all class code now - Unfortunately you can see I've commented all the complicated stuff out for testing, it's just a single line now using clockworks logger that never appears in the log/chrome extension.Retinite
@HollyGrant did you find a solution?Tala
No luck with this one ? Dealing with the same myself.Mendymene
T
0

try adding Dispatchable and Queueable to your use

use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
Trickster answered 18/6 at 20:5 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Monocarpic

© 2022 - 2024 — McMap. All rights reserved.