1

I have a controller, that calls a job, that calls a service.

The controller is updating fine:

public function myFunction(Request $request)
{
    $job = new job();
    $this->dispatch($job);
    return new JsonResponse(true);
}

If I change the JsonResponse to false, it will send false (for example).

Then I have a job in app/Jobs/job that does something:

public function handle()
{
    $myService = new MyService();
    $myService->doThis();
}

And the service does something else:

class MyService
{

    public function doThis()
    {
        //Does a thing that throws an exception
    }
}

The job as well as the services won't update at all no matter what I do. I tried even deleting the job as well as the service file but it just stays there. I've tried to clear all the caches to no avail. Any help?

prgrm
  • 3,734
  • 14
  • 40
  • 80

1 Answers1

3

I am answering the question as I found what was wrong while writing it.

If the queue is functioning (php artisan queue:work) the job and even the service will be cached. A simple restart will fix the problem.

Hopefully this helps someone else.

prgrm
  • 3,734
  • 14
  • 40
  • 80
  • 1
    This is pretty clearly stated in the documentation: *"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 code base after they have been started. So, during your deployment process, be sure to restart your queue workers. In addition, remember that any static state created or modified by your application will not be automatically reset between jobs."* - https://laravel.com/docs/9.x/queues#running-the-queue-worker – Tim Lewis Apr 25 '22 at 15:00