npm.io
2.22.7 • Published 4d ago

@medusajs/workflow-engine-redis

Licence
MIT
Version
2.22.7
Deps
3
Size
196 kB
Vulns
0
Weekly
0
Stars
36.3K

Medusa logo

@medusajs/workflow-engine-redis

Documentation | Website

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome! Discord Chat Follow @medusajs

Redis Workflow Engine Module for Medusa: runs workflows and tracks their executions, subscribers, retries, timeouts, and scheduled workflow jobs using Redis and BullMQ. It's the recommended Workflow Engine Module for production and replaces the default in-memory engine. It ships with @medusajs/medusa but isn't registered by default, so add it to medusa-config.ts.

At a glance

Package @medusajs/workflow-engine-redis
Type Infrastructure Module
Module key Modules.WORKFLOW_ENGINE ("workflows")
Registered by default No (on Medusa Cloud, registered automatically when REDIS_URL is set)
Import from @medusajs/medusa/workflow-engine-redis

Installation

No installation needed. The module ships with @medusajs/medusa. You need a running Redis server.

Usage

Register the module in medusa-config.ts. All options go inside the redis object:

import { defineConfig } from "@medusajs/framework/utils"

module.exports = defineConfig({
  // ...
  modules: [
    {
      resolve: "@medusajs/medusa/workflow-engine-redis",
      options: {
        redis: {
          redisUrl: process.env.WE_REDIS_URL,
        },
      },
    },
  ],
})

Configuration

Options of the redis object:

Option Type Description Default
redisUrl string Redis connection URL. Required (the module throws on startup without it or the deprecated url). -
redisOptions RedisOptions ioredis client options. -
queueName string Name of the main queue, which handles workflow retries, step timeouts, and transaction timeouts. "medusa-workflows"
jobQueueName string Name of the queue that runs scheduled workflow jobs. "medusa-workflows-jobs"
queueOptions QueueOptions BullMQ queue options (without connection) applied to all queues. -
workerOptions WorkerOptions BullMQ worker options (without connection) applied to all workers. -
mainQueueOptions QueueOptions Overrides queueOptions for the main queue. -
mainWorkerOptions WorkerOptions Overrides workerOptions for the main worker. -
jobQueueOptions QueueOptions Overrides queueOptions for the scheduled jobs queue. -
jobWorkerOptions WorkerOptions Overrides workerOptions for the scheduled jobs worker. -
cleanerQueueOptions QueueOptions Overrides queueOptions for the queue that removes expired workflow executions. -
cleanerWorkerOptions WorkerOptions Overrides workerOptions for the cleaner worker. -
pubsub { url: string, options?: RedisOptions } Separate Redis connection for pub/sub. Same connection as redisUrl and redisOptions
url string Deprecated. Use redisUrl. -
options RedisOptions Deprecated. Use redisOptions. -

Resources