Laravel Job doesn't get scheduled with delay()

Posted 6 months ago by arximughal

I am trying to schedule a job in the queue as described in the example here but it's getting processed immediately.

Here's my code dispatching new job:

RemoveTorrent::dispatch($torrent)
    ->onQueue('RemoveTorrent')
    ->delay(now()->addMinutes(15));

Here's the job:

<?php
    
    namespace App\Jobs;
    
    use Illuminate\Bus\Queueable;
    use Illuminate\Queue\SerializesModels;
    use Illuminate\Queue\InteractsWithQueue;
    use Illuminate\Contracts\Queue\ShouldQueue;
    use Illuminate\Foundation\Bus\Dispatchable;
    
    use App\Services\MyService;
    
    
    class RemoveTorrent implements ShouldQueue
    {
        use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
        
        /**
         * Create a new job instance.
         *
         * @return void
         */
        
        protected $torrent;
        
        public function __construct(Modal $modal)
        {
            $this->torrent = $modal;
        }
        
        /**
         * Execute the job.
         *
         * @return void
         */
        public function handle(MyService $myService)
        {
            //
        }
    }

Please sign in or create an account to participate in this conversation.