Future queue operations

alt=
DannyA
@dannya
9 years ago
584 posts
Is it possible to set a future date for a queue operation? Specifically, I am creating a song/blog/whatever and I have sharing enable. The creation/release date is in the future. But the sharing operation is going to the queue right away. I want the queue operation to happen on the release date.
updated by @dannya: 06/26/15 08:36:40PM
brian
@brian
9 years ago
10,148 posts
DannyA:
Is it possible to set a future date for a queue operation? Specifically, I am creating a song/blog/whatever and I have sharing enable. The creation/release date is in the future. But the sharing operation is going to the queue right away. I want the queue operation to happen on the release date.

Yes - when you create the queue, you can tell it to "sleep" a specific number of seconds before it can be picked up by a worker - i.e.

$_queue = array(
    'key' => 'value
);
jrCore_queue_create('YourModule', 'queue_name', $_queue, 600);

It's the 4th arg - that "600" says sleep for 600 seconds (10 minutes) before making the queue available to a worker.

If you find you need to extend the sleep time, you can come back and sleep it longer - i.e.

jrCore_queue_sleep(5, 600);

It takes the Queue ID as the first arg, and the number of seconds from NOW to sleep.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
DannyA
@dannya
9 years ago
584 posts
Is there a time limit? Someone could set a date days/months/years ahead.
michael
@michael
9 years ago
7,717 posts
perhaps a more technical solution to the creation system. When the item is created if its a date in the future instead of creating it, put it into a separate table in the DB and then use the daily maintenance to cue that days stuff each day.

So the daily maintenance checks for any items that are due 'today' and creates them and queue's them then.

That would remove the need to set a date fore the queue. (one idea)

Tags