Laravel Queue is one of the best feather of Laravel 5.x. When we want to make our site fast and we have to fetch and store large amount of data then we will run our query on back end. In Laravel 5.x by using queue we can run time consuming on back end , Such as sending an e-mail,fetching large amount of records etc.
Laravel Queue file is stored in app/config/queue.php. For this we will use n number of web services which are already available in Laravel, which includes a Beanstalkd, IronMQ, Amazon SQS, Redis, and synchronous (for local use)
Laravel 5.x includes an Artisan command that will run new jobs as they are pushed onto the queue. You may run the listener using the queue:listen command:
Command:
php artisan queue:listen
Use of Queue:
To perform a new job onto the queue we will use following syntax.
Queue::push('SendEmail', array('message' => $message));
In this "first argument is the name of the class and should be used to process the job and second argument is the array of data that should be pass to the handler.
And In handler we have fire function there we write our code we want to perform in back end.
Example
class SendEmail {
public function fire($job, $data)
{
//Here we write our function.
}
}
By this way we can define our backend process in Laravel 5.x.
0 Comment(s)