Eric Chapman
Eric Chapman

Reputation: 9

Dispatching Queue Jobs (local Dev Mac) Not Working

I try to dispatch a job on my local dev machine.

I setup my .env and queue config ; QUEUE_CONNECTION=database

I also did the migrate :

php artisan queue:table

php artisan migrate

Then create my job something like : myjob::dispatchNow();

And finally run my worker: php artisan queue:work

With all that the code launch and execute well but not the job. The job is not created in the database jobs table. (nor in faield_jobs

Is I am missing any step?

Do I need something else on my local machine to run jobs queue?

Thanks for any help.

Upvotes: 0

Views: 385

Answers (1)

Kurt Friars
Kurt Friars

Reputation: 3764

You are using synchronous dispatching by using myjob::dispatchNow(). The database does not need to be involved as it runs the job during the same request and your queue worker never knows about it. It is equivalent to having QUEUE_DRIVER=sync.

If you use myjob::dispatch() before you start the queue worker, you will see the job in your database.

Upvotes: 0

Related Questions