Wondering Coder Wondering Coder - 1 year ago 119
PHP Question

How to execute a job immediately using Laravel Queue

I have a sign up form which sends an email notification to the user email and I used Laravel Queue for all my background process (e.g. Mail::queue...).

My question is, say I have a 20 queued jobs in my table. And I always want to prioritize all email invitations first, I don't want it to wait. Is this possible? I still want to use the queue principle though.

Answer Source

You could setup multiple queues. For example one for background jobs with low priorities and one for email with a high priority.

See this link from the Laravel documentation regarding assign jobs to specific queues. Pushing Jobs Onto The Queue. Look into 'Specifying The Queue For A Job'.

After you have done setting this up you can assigning priorities to the queues. See the following link to the Laravel documentation. Running The Queue Listener. Look into 'Queue Priorities'.

Quote from Laravel documentation:

In this example, jobs on the high queue will always be processed before moving onto jobs from the low queue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download