vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.63k stars 997 forks source link

Prefixes in BullMQ: Multiple queues in one Redis #2645

Closed alebak closed 1 week ago

alebak commented 8 months ago

Is your feature request related to a problem? Please describe. Currently, I am facing an issue where only one Redis queue can be configured in Vendure, as it is hardcoded. This becomes a problem when I need to manage multiple Vendure instances on a single Redis server, as I cannot differentiate the queues.

Describe the solution you'd like I would like to propose the implementation of a feature that allows to set custom prefixes for queues in BullMQ, which would facilitate the management of multiple Vendure instances on a single Redis server. This could be achieved by introducing an additional configuration in Vendure that allows to set a unique prefix for each instance.

Describe alternatives you've considered As an alternative, I have considered running separate instances of Redis for each Vendure instance. However, this is not a practical and efficient solution, as it could significantly increase costs and infrastructure complexity, especially when multiple preview environments are involved in the development of a team Vendure project.

I hope that this proposal will be considered to improve Vendure's functionality and flexibility.

michaelbromley commented 8 months ago

Hi,

I agree that this would be a good feature to support. Would you be interested in creating a PR for this? If so, do it against the minor branch.

dlhck commented 1 week ago

@michaelbromley I think the right solution for that is to use Redis databases. By default every connection uses the logical DB index 0. That can already be configured like that:

  BullMQJobQueuePlugin.init({
    connection: {
      host: env.REDIS_QUEUE_HOST,
      port: env.REDIS_QUEUE_PORT,
      maxRetriesPerRequest: null,
      db: env.REDIS_QUEUE_DB // set a different numeric DB index for every instance,
    },
  }),

@alebak just use a different DB index for every Vendure instance. If that's not enough, please re-open the issue again and we'll taker a closer look.