Support the ongoing development of Laravel.io →
posted 10 years ago
Queues
Last updated 2 years ago.
0

Hi

Whether to use cron or a queue really depends on the nature of the task at hand. If you're sending an email to everyone whose account expires one month from today, you want to execute that once per day, and a cron job would be ideal for this.

Adding something to a queue is usually triggered at some point in the page request. For example, queue sending an email to the user, or queue rendering a thumbnail from their profile pic. These things take a "long time" from the perspective the request-response cycle, so are shoved into the background to speed up returning the page to the user.

One option to look at is the Dispatcher package for Laravel. Basically set up a cron job to run every minute, and based on the schedule you set in the artisan command (eg php artisan sendOneMonthExpNotice) it will executre it on whatever schedule you want. Saves setting up multiple cron jobs per project. Just one cron job, running every minute, and all your commands will be processed on their own schedule.

Last updated 2 years ago.
0

cron or at only schedule the running of a "task" (Command) .. tasks can be considered a single chunk of work, or multiple. Crons can run a Job (in a queue) ... Jobs know very little - $job and $data and should be able to operate on its own.

You can cron up Commands to run, or use the Dispatcher as above, but there isn't a real way to "fire" a Job that runs in a queue, cleanly, without a Command - that I know of

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

lab6net lab6net Joined 30 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.