taskforcesh / bullmq-pro-support

Support repository for BullMQ Pro edition.
1 stars 0 forks source link

4.x: Migration from obsolete QueueSchedulerPro #28

Closed hardcodet closed 1 year ago

hardcodet commented 2 years ago

I just saw in the release notes that the latest Pro version marks QueueSchedulerPro as obsolete:

Remove QueueSchedulerPro class. WorkerPro class should handle QueueSchedulerPro functionalities.

Is there anything to consider, or can we just replace QueueSchedulerPro by QueueScheudler without any further changes? Or can we even completely skip the scheduler creation?

Here's my current setup:

        // workers need persistent connections with endless retries, queues
        // can (and should) fail faster to prevent clients being blocked indefinitely
        const endlessRetryConnection = new Redis(this.config.redisUri, {
            maxRetriesPerRequest: null,
            enableReadyCheck: false,
            retryStrategy: (times: number) => Math.min(Math.exp(times), 15000),
        });

        const limitedRetryConnection = new Redis(this.config.redisUri, {
            maxRetriesPerRequest: 20,
            enableReadyCheck: false,
            retryStrategy: (times: number) => Math.min(Math.exp(times), 15000),
        });

        const queue = new QueuePro<T>(queueName, { connection: limitedRetryConnection });
        const scheduler = new QueueSchedulerPro(queueName, { connection: endlessRetryConnection });
        const worker = new WorkerPro(queueName, async (job: Job) => {
            // no try/catch needed - we're listening on the failed event of the worker
            await callback(job.data, job);
        }, {
            connection: endlessRetryConnection,
            group: {
                // force jobs of the same group to execute sequentially
                concurrency: 1,
            },
            concurrency: 10, // bull default is 1
        });

Thanks for your advice :)

manast commented 2 years ago

As far as I know it should be just a matter of removing the QueueSchedulerPro altogether. @roggervalf do you have any other input?

roggervalf commented 2 years ago

Since version 4, it should be safe on removing QueueSchedulerPro