O
O
Oleg Trubin2016-01-10 16:40:48
Laravel
Oleg Trubin, 2016-01-10 16:40:48

Laravel 5.1. How to start and stop a specific job in a queue?

Hello.
There is a certain job which should be infinitely executed with a delay let's say in 30 sec.

class SomeJob extends Job implements SelfHandling
{
    use InteractsWithQueue;

    public function __construct()
    {
        //
    }

    public function handle()
    {
        //что-то делаем
        $this->release(30);
    }
}

You need to start and stop it through the web interface.
How to start is basically clear, somewhere in the controller:
$job = (new SomeJob())->onQueue('someQueue');
$this->dispatch($job);

It does not reach me how to stop this particular Job instance
. I understand that there is a method.
$this->delete();
But I do not understand how to get this particular object, given that there may be several of them.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Dupliy, 2016-01-14
@booomerang

You need to use the Queue facade to retrieve jobs. You need to get the queue itself first, extract it from it by job id.
See here:
stackoverflow.com/questions/25107359/deleting-runn...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question