Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alihoushyaripour's avatar

How to push a job into queue?

Hi,

I have a job and want to push it in queue to start with 500 ms delays, I was write this code:

\Queue::push(new SendSimpleNotification('token', 'title', 'content'));

But when code is running and come to this line, if this job take 5 seconds to finished, code wait 5 seconds in this line and it doesn't pass quickly from this line to run it queue later.

Notice that I use a simple curl in my job class that take 5 seconds. (in handle function).

0 likes
3 replies
Talinon's avatar

Does your SendSimpleNotification class implement the lluminate\Contracts\Queue\ShouldQueue interface? That will instruct Laravel to run the job asynchronously - or in other words, won't cause your application to wait for the job to complete.

use Illuminate\Contracts\Queue\ShouldQueue;

class SendSimpleNotification implements ShouldQueue
{
//  ...
}
alihoushyaripour's avatar

@TALINON - Yes, this is my job code:

class SendSimpleNotification implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function __construct()
    {
        //
    }

    public function handle()
    {
        //
    }
}

Is the problem elsewhere?

Please or to participate in this conversation.