2

my function in controller Calling parallel and i create a job for use queue in laravel Because parallel call causing the problem

i call this job in my function :

$this->dispatch(new ProcessReferal($orderId));

and i run this command in terminal :

php artisan queue:work --tries=3

But my job is still running in parallel

And processes the process simultaneously

what's wrong?

2 Answers 2

3

If you are checking it on Local server. Then, You have to add QUEUE_DRIVER=database in .env file.

QUEUE_DRIVER=sync is used for parallel call

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

Comments

1

Hi there,

With queue laravel, you need config some info in your code:

See more: https://laravel.com/docs/5.8/queues#connections-vs-queues

First:

  • Driver: default sync, so you need change it to: database, redis... You can change it in .env file (QUEUE_DRIVER=database...)

  • Connections: Very important if you setting driver is database and use mutil DB for your project.

Second:

  • Laravel queue have some config, but i think we need see 3 thing: retry_after, timeout, tries. When you work with large job, retry_after and timeout is very important.

Hope it can help you.

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.