Jobs in Laravel 5.4

0

I'm using Jobs in Laravel, which implements queues with redis.

By submitting a form I call the function:

private function allUsersNotifications($title, $description) {
    $users = $this->userRepo->search();

    dispatch(new NotificationsAllUsers($users, $title, $description));      
}

and inside the Job (NotificationsAllUsers) I do:

    class NotificationsAllUsers implements ShouldQueue {

    use InteractsWithQueue,
        Queueable,
        SerializesModels;

    public $users;
    public $title;
    public $description;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($users, $title, $description) {
        $this->users = $users;
        $this->title = $title;
        $this->description = $description;  
        Log::info(3);
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle() {
        Log::info(4);
    }

}

When running the job, the log prints me well, but if within the handle method deletion Log :: info (4) and I want to print something else, like Log :: info (1), I still print the 4. Already it's the second time it happens to me that I modify something in the handle of a job and as it does not take the change, as it is in cache.

I have removed the redis and queues cache and it remains the same.

    
asked by Juan Pablo B 21.06.2017 в 14:02
source

1 answer

1

In the documentation says:

  

Remember, queue workers are long-lived processes and store the booted application state in memory. As a result, they will not notice changes in your base code after they have started. So, during your deployment process, be sure to restart your queue workers.

Therefore you will have to throw:

php artisan queue:restart

The answer is already late afternoon but maybe it will work for another.

    
answered by 12.10.2017 / 23:01
source