3

I am trying to execute job through dispatch() method using

  1. laravel 5.4
  2. redis-server
  3. supervisor

I have done queue config like 'default' => env('QUEUE_DRIVER', 'redis').

  1. I am call dispatch() method in my app/Services file

dispatch(new SavePropertyImages($pid_list));

  1. the following is my job file in app/Jobs:

    namespace App\Jobs;
    
    use App\Property;
    use App\Services\CreaBase;
    use Illuminate\Bus\Queueable;
    use Illuminate\Queue\SerializesModels;
    use Illuminate\Queue\InteractsWithQueue;
    use Illuminate\Contracts\Queue\ShouldQueue;
    use Illuminate\Foundation\Bus\Dispatchable;
    
    class SavePropertyImages implements ShouldQueue
    {
        use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    
        protected $pid;
        protected $creaBase;
        public $timeout = 300;
        public $tries = 1;
        /**
         * Create a new job instance.
         *
         * @return void
        */
        public function __construct($pid)
        {
            $this->pid = $pid;
        }
    
        /**
         * Execute the job.
         *
         * @return void
        */
        public function handle()
        {
                $this->creaBase = new CreaBase();
            if (!$this->creaBase->isLogin){
                    $this->creaBase->init();
            }
                $this->creaBase->saveAllImages("Property", $this->pid);
        }
    }
    

When I call a dispatch(new SavePropertyImages($pid_list)) method, the job's __construct() method calls, but it does not call handle() function.

Do you have any ideas?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Maulik Kanani
  • 59
  • 1
  • 6

1 Answers1

2

bingo, I got the answer

my handle() function does not call. because I set a supervisor but not start the supervisor process that's why my queue:work redis process not start and my job does not assign to redis server and my job was not to execute.

first off all I start my supervisor service and my queue works fine.

Maulik Kanani
  • 59
  • 1
  • 6