pg-boss icon indicating copy to clipboard operation
pg-boss copied to clipboard

Scheduling many individual jobs for the same queue

Open jpike88 opened this issue 2 years ago • 3 comments

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?

jpike88 avatar Nov 10 '23 04:11 jpike88

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

timgit avatar Nov 11 '23 02:11 timgit

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.

jpike88 avatar Nov 11 '23 02:11 jpike88

You can use the startAfter property to schedule jobs.

timgit avatar Nov 11 '23 02:11 timgit