1

I'm working on queue and I found custom queue won't be run.

I run php artisan queue:work --queue=emails and I dispatch queue MyJob::dispatch()->onQueue('emails')->delay(now()->addMinutes(1)).

In database table jobs will be like this:

id queue payload
1 emails ...

After 1 minute:

id queue payload
2 default ...

It seems queue emails is processed, and remove from database. Then create another job for queue default with the same payload and job queue default will never run except I run php artisan queue:work --queue=emails,default

In Laravel documentation not mention to always run queue default. https://laravel.com/docs/8.x/queues#specifying-the-connection-queue

Is it correct behaviour?

1 Answer 1

0

In my case, the problem of duplicate rows occurs when I set QUEUE_CONNECTION to database in .env file like this:

QUEUE_CONNECTION=database

I solved the problem by keep value of QUEUE_CONNECTION as default of Laravel sync

And add database to command like this:

php artisan queue:work database --queue=my_custom_queue_name
Sign up to request clarification or add additional context in comments.

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.