timgit / pg-boss

Queueing jobs in Node.js using PostgreSQL like a boss
MIT License
1.73k stars 144 forks source link

Scheduling many individual jobs for the same queue #430

Open jpike88 opened 8 months ago

jpike88 commented 8 months ago

Hello,

I same to have a problem understanding the documentation.

This code:

await boss.schedule(
        'my_queue_name',
                '0 8 * * *', // queue for 8am
        {
            // some data here
        },
        {
            tz: 'Australia/Sydney',
        }
    );

I want run it hundreds of times throughout the day but when I test this, I just see the one row in the schedule table, it's like I can only schedule one job per queue at any given time?

timgit commented 8 months ago

That's correct. schedule() overwrites any previous schedule for the specified queue.

jpike88 commented 8 months ago

Do you have a recommendation for the pattern I should use? I'm trying to use pgboss to defer notifications generated during the night to be picked up and sent in the morning.

timgit commented 8 months ago

You can use the startAfter property to schedule jobs.