Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BullMQ reusing redis connections #1236

Closed
Lord-Jerry opened this issue May 10, 2022 · 4 comments
Closed

BullMQ reusing redis connections #1236

Lord-Jerry opened this issue May 10, 2022 · 4 comments

Comments

@Lord-Jerry
Copy link

Lord-Jerry commented May 10, 2022

I am trying to add logic to re-use Redis connections with bullMQ using this instruction from the bullMQ docs.

I am using the most recent (1.81.1) BullMQ npm version.

I followed the instruction on the docs, to create an object that includes a createClient method.
But I get the following error TS2559.

Type '{ createClient: (type: string, redisOpts: any); }' has no properties in common with type 'QueueOptions'.

Code Sample

import Redis from 'ioredis'
import { Queue } from 'bullmq'

const sharedRedisClientConnection = new Redis(REDIS_URL as string, redisConfig)
const sharedRedisSubscriberConnection = new Redis(REDIS_URL as string, redisConfig)

const options = {
  createClient: (type?: string) => {
    switch (type) {
      case 'client':
        return sharedRedisClientConnection
      case 'subscriber':
        return sharedRedisSubscriberConnection
      default:
        return new Redis(REDIS_URL as string, redisConfig)
    }
  }
}

const userQueue = new Queue('users', options)

node version: v16.13.0
typescript version: v4.5.5

@manast
Copy link
Contributor

manast commented May 12, 2022

The documentation you are pointing to is for Bull, not BullMQ. In BullMQ you do not need to use that pattern, just pass directly the redis connection that you want to reuse and if BullMQ can reuse it it will do so automatically:
https://docs.bullmq.io/guide/connections

@manast manast closed this as completed May 12, 2022
@elovin
Copy link

elovin commented Apr 6, 2023

@manast The documentation about reusing connections is on the bullmq docs website: https://docs.bullmq.io/bull/patterns/reusing-redis-connections
so should this not be removed when it is no longer needed / supported ?

@RoyNelsonCondor
Copy link

@elovin @manast
is it no longer need / supported ?

@manast
Copy link
Contributor

manast commented Nov 20, 2023

@RoyNelsonCondor what is not longer needed / supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants