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:
1module.exports = {
2  // ...
3  redis: {
4    enabled: true,
5    config: {
6      connections: {
7        // ...
8        queue: {
9          connection: {
10            host: env('REDIS_HOST', '127.0.0.1'),
11            port: env('REDIS_PORT', 6379),
12            password: env('REDIS_PASSWORD'),
13            username: env('REDIS_USERNAME', 'default'),
14            maxRetriesPerRequest: null,
15          },
16        },
17      },
18    },
19  },
20  // ...
21};

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:
1module.exports = {
2  // ...
3  bullmq: {
4    enabled: true,
5    config: {
6      connectionName: 'queue', // Name of the Redis connection to use
7    },
8  },
9  // ...
10};

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

📖 Usage

Creating a Queue

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

Adding Jobs to a Queue

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

Creating a Worker

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

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:

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

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

Worker Options

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

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

3 GitHub stars18 weekly downloads

Last updated

12 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.