timgit / pg-boss

Queueing jobs in Postgres from Node.js like a boss
MIT License
2.15k stars 160 forks source link

Scheduling many individual jobs for the same queue #430

Closed jpike88 closed 3 months ago

jpike88 commented 1 year 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 1 year ago

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

jpike88 commented 1 year 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 1 year ago

You can use the startAfter property to schedule jobs.