Laravel 4 has a great list of features in terms of Queues. This question is with respect to the Queue method Queue.later()
API Documentation the first parameter being the delay
.
A Cron is basically made use of to execute recurring tasks.
If the below snippet were to be made more generic with the time being configurable as well can:
- This be used as an alternative to CRON jobs?
- Would this be fail safe approach to use assuming we use IronMQ
-
class SendEmail {
public function fire($job, $data)
{
//Connect to SMTP and send email
$job->delete();
//Recall the queue with a delay
Queue::later(60,'SendEmail@send', array('message' => $message));
}
}
//app/events/MailHandler.php
public class MailHandler(){
public function onMailListenerStarted(){
Queue::push('SendEmail@send', array('message' => $message));
}
}