S
S
sv82017-09-11 08:25:05
Laravel
sv8, 2017-09-11 08:25:05

How to remove irrelevant tasks from the queue in Laravel?

Good afternoon!
Task:
The site creates an event scheduled for a specific time. Some time before it starts, certain tasks must occur: notifications, invitations, etc. should be sent.
At the moment, when creating an event, I push all the tasks that must be completed before it starts to a queue with an appropriate delay. (I use a database as a driver for queues)
Problems:
1) If an event is deleted, then the tasks in the queue regarding this event are no longer relevant. I did not find in the interface for working with queues in Laravel how it is possible (and is it possible / necessary?) to clear the task queue.
2) If the start time of the event changes, it is necessary to schedule new tasks in the queue, in accordance with the current start time of the event (because, let's say, the notification should fall to the user exactly an hour before the start of the event) . But at the same time, old tasks regarding this event are stored in the queue, again, how to cut them out of the queue?
Please, who faced a similar problem, tell me how to solve it correctly? How to get rid of irrelevant tasks in the queue in Laravel?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vism, 2017-09-11
@sv8

Queues are for executing events on an external thread so to speak.
And you started to "moonshine drive."
Make a task that will check the conditions and execute the code. And it will already check itself from the data source.

S
Sergey Sokolov, 2017-09-11
@sergiks

Add a trait and the delete()Illuminate\Queue\InteractsWithQueue method will appear with it . See the Manually Accessing The Queue documentation section .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question