laravel - Have a queue job always running -


i have queue job need have running.

that means when job finished processing, should start job on again.

how can this?

here's job:

<?php  namespace app\jobs;  use app\user; use app\post;  use app\jobs\job; use illuminate\contracts\mail\mailer; use illuminate\queue\serializesmodels; use illuminate\queue\interactswithqueue; use illuminate\contracts\queue\shouldqueue;  class postjob extends job implements shouldqueue {     use interactswithqueue, serializesmodels;      protected $user;      public function __construct(user $user)     {         $this->user = $user;     }      public function handle()     {         $posts = post::where('user_id', $this->user->id)             ->get();          foreach ($posts $post) {             // perform actions         }     } } 

here's job controller:

<?php  namespace app\http\controllers;  use app\user;  use illuminate\http\request; use app\jobs\sendreminderemail; use app\http\controllers\controller;  class usercontroller extends controller {     public function startpostjob(request $request, $id)     {         $users = user::all();          foreach ($users $user) {             $this->dispatch(new postjob($user));         }     } } 

the queue meant 1 time request, not continuous job running. architecture should move more of cron job setup can set intervals re-run desired code.

have @ task scheduling documentation here https://laravel.com/docs/5.1/scheduling


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -