🚀 New Release: Strapi AI Translations! Learn more

Strapi plugin logo for BullMQ

BullMQ

Strapi Plugin BullMQ is a plugin that integrates Bull Queue with Strapi, providing robust job queue management capabilities for your Strapi applications.

strapi-plugin-bullmq

Strapi Plugin BullMQ is a plugin that integrates BullMQ with Strapi, providing robust job queue management capabilities for your Strapi applications.

✅ Requirements

  • Strapi v5
  • @strapi-community/plugin-redis

🔧 Installation

  1. Install the required Redis plugin & BullMQ plugin:
npm install @strapi-community/plugin-redis strapi-plugin-bullmq

or

yarn add @strapi-community/plugin-redis strapi-plugin-bullmq

or

pnpm add @strapi-community/plugin-redis strapi-plugin-bullmq

For more details, see: https://strapi-community.github.io/plugin-redis

  1. Configure the Redis connection for BullMQ in your config/plugins.js or config/plugins.ts:
module.exports = {
  // ...
  redis: {
    enabled: true,
    config: {
      connections: {
        // ...
        queue: {
          connection: {
            host: env('REDIS_HOST', '127.0.0.1'),
            port: env('REDIS_PORT', 6379),
            password: env('REDIS_PASSWORD'),
            username: env('REDIS_USERNAME', 'default'),
            maxRetriesPerRequest: null,
          },
        },
      },
    },
  },
  // ...
};

Note: maxRetriesPerRequest must be set to null for persistent connections. For more details, see: https://docs.bullmq.io/bull/patterns/persistent-connections

  1. Configure the plugin in your config/plugins.js or config/plugins.ts:
module.exports = {
  // ...
  bullmq: {
    enabled: true,
    config: {
      connectionName: 'queue', // Name of the Redis connection to use
    },
  },
  // ...
};

Note: connectionName must be the same as the name of the Redis connection configured in the previous step.

📖 Usage

Creating a Queue

const queue = strapi.plugin('bullmq').service('queue').get('my-queue');

Adding Jobs to a Queue

await queue.add('job-name', { data: 'some data' });

Creating a Worker

const worker = strapi
  .plugin('bullmq')
  .service('worker')
  .create(queue, async (job) => {
    console.log('Processing job:', job.name, job.data);
    // Process the job
  });

Recommendation: It is recommended to create and start workers in your bootstrap.ts or bootstrap.js file to ensure they are initialized when the Strapi application starts.

Note: The plugin automatically handles connection cleanup when the Strapi destroy event is fired, so manual cleanup is not required.

Job Options

You can pass options when adding jobs:

await queue.add(
  'job-name',
  { data: 'some data' },
  {
    delay: 5000, // Delay in milliseconds
    priority: 1, // Priority (higher numbers have higher priority)
    attempts: 3, // Number of attempts
  }
);

For more details, see: https://docs.bullmq.io/guide/queues

Worker Options

const worker = strapi
  .plugin('bullmq')
  .service('worker')
  .create(queue, handler, {
    concurrency: 5, // Number of concurrent jobs
    limiter: { max: 10, duration: 1000 }, // Rate limiting
  });

For more details, see: https://docs.bullmq.io/guide/workers

🤝 Contributing

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your PR:

  • Follows the existing code style
  • Includes appropriate tests
  • Updates documentation as needed

� License

This project is licensed under the MIT License - see the LICENSE file for details.

📬 Contact & Support

🔗 External Links

Install now

npm install strapi-plugin-bullmq

STATS

4 GitHub stars44 weekly downloads

Last updated

95 days ago

Strapi Version

5.27.0 and above

Author

github profile image for Hung Pham - @revolabs-io
Hung Pham - @revolabs-io

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.