0

I have a laravel queue setup to a database. When I run dd(env('QUEUE_DRIVER')) I get database back. When I create a job it is run right away. I would like the job to be queued until I run php artisan queue:work. What do I need to do to have the job not run right away. Thanks!

Edit 1:

Dispatch Code:

for ($i=0; $i < 100; $i++) { 
        $job = new UpdateJob("");
        dispatch($job);
}

Job Code:

public function handle(){
    sleep(30);
    SlackApi::SendMessage("Job!");
}

When I run this I get a slack message every 30 seconds. But none of these jobs are being stored in the DB.

Edit 2:

Even when I add ->delay(Carbon::now()->addMinutes(10)) to the job the job is still run right away.

8
  • When you put job into queue it will run as quick as possible. Job feature created for purpose when you have to do many tasks so they are queued in the queue and will perform one by one. Maybe this article can help you: laracasts.com/discuss/channels/laravel/… Commented Jun 29, 2017 at 6:56
  • Show me your lines of code where you dispatch your job Commented Jun 29, 2017 at 7:06
  • @vietnguyen09 See Edit Commented Jun 29, 2017 at 9:33
  • You not run queue:work but still see new record inserted in your DB? Commented Jun 29, 2017 at 9:35
  • I did not run queue:work the job is just being done. And I don't see anything in the DB. Commented Jun 29, 2017 at 9:36

2 Answers 2

1

The issue seems to come from upgrading from v5.1 to v5.4 I added Illuminate\Bus\BusServiceProvider::class to my providers in app.php and that fixed everything.

Sign up to request clarification or add additional context in comments.

Comments

0

Is any supervisor running? if the supervisor is configure the queue will be take care of the job as son as it's added to the queue. if you want a delayed dispatch of the job you must specify the delay. Take a look into https://laravel.com/docs/5.4/queues#delayed-dispatching for more details

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.