EdyStauch's avatar

Dispatching JOBs not working on production

My app work ok in local and homologation environment. Jobs are dispatched ok to a database queue and are processed with supervisor.

In production environment the dispatch doesn't work and do not display any errors. By doesn't work i mean no records are created on jobs table or failed_jobs table. I already tried to dispatch by artisan tinker trying to identify the issue, but nothing happens.

On tinker when i dispatch i see this:

MyJob::dispatch('test'); Illuminate\Foundation\Bus\PendingDispatch {#3817}

My .env file contains

QUEUE_CONNECTION=database

My queue.php contains:

'database' => [ 'connection' => 'mysql', 'driver' => 'database', 'table' => 'jobs', 'queue' => 'default', 'retry_after' => 400, 'after_commit' => false, ],

0 likes
5 replies
DavidSpooner's avatar

Have you confirmed that the queue worker is running on the production server and that Supervisor is properly installed and configured there as well?

EdyStauch's avatar

Thanks for the answer. Yes, it's running. I also had the queue run via artisan to test. But from what I understand, even if it wasn't, the system should generate a record in the jobs table. This is my problem, it's not generating the records in the jobs table and it doesn't show any error about it, it doesn't go to the failed_jobs table either.

CodeNathan's avatar

Based on the other answers can I ask the following :

  • Have you checked the log files to see if there are any errors there?
  • Can you make sure that the MyJob class is located in the correct namespace? If the class can't be found, the dispatch process will fail silently and no records will be added to the jobs table.

also something I may suggest to try , see if you get an errors by dispatching the job synchronously by using:

MyJob::dispatchNow('test');

This will run the job immediately, rather than adding it to the queue. This will help you to identify if the problem is with the queue worker or if it is somewhere else in your code.

2 likes

Please or to participate in this conversation.