Whenever you change code for a Job, you must restart the queue worker because queue workers are long-lived processes and store the booted application state in memory.
https://laravel.com/docs/11.x/queues#queue-workers-and-deployment
Hello,
Does laravel have any kind of cache for jobs? I have changed the code of my job and somehow the app executes the code of the old job. If the file is removed (or renamed) the dispatch for this job returns a job not found error.
I have made sure that the file on the server has changed and it did.
In 24 years it's the first time that something like that happens.
I have also created a route/controller to test out the
public function test()
{
ProcessVideoJob::dispatch('hello')->onQueue('video_encoding');
}
and
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class ProcessVideoJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $video_code;
/**
* Create a new job instance.
*/
public function __construct(string $video_code)
{
$this->video_code = $video_code;
}
/**
* Execute the job.
*/
public function handle(): void
{
Log::error("Say the testing text {$this->video_code}.");
}
}
But it magically returns an error because he execute the old code (that was about processing the video). Locally the file has changed and I made sure that. On the server the file has changed and I made use of that as well.
I don't use any kind of cache on the server.
Thanks, Simon
Whenever you change code for a Job, you must restart the queue worker because queue workers are long-lived processes and store the booted application state in memory.
https://laravel.com/docs/11.x/queues#queue-workers-and-deployment
Please or to participate in this conversation.