www/apps/resources/app/infrastructure-modules/workflow-engine/redis/page.mdx
import { Table, Prerequisites } from "docs-ui"
export const metadata = {
title: Redis Workflow Engine Module,
}
The Redis Workflow Engine Module uses Redis to track workflow executions and handle their subscribers. In production, it's recommended to use this module.
<Note title="Using Cloud?">Our Cloud offering automatically provisions a Redis instance and configures the Redis Workflow Engine Module for you. Learn more in the Redis Cloud documentation.
</Note><Prerequisites items={[ { text: "Redis installed and Redis server running", link: "https://redis.io/docs/getting-started/installation/" } ]} />
Add the module into the modules property of the exported object in medusa-config.ts:
export const highlights = [ ["8", "redisUrl", "The Redis connection URL."] ]
module.exports = defineConfig({
// ...
modules: [
{
resolve: "@medusajs/medusa/workflow-engine-redis",
options: {
redis: {
redisUrl: process.env.WE_REDIS_URL,
// ...other Redis options
},
},
},
],
})
Make sure to add the following environment variables:
WE_REDIS_URL=<YOUR_REDIS_URL>
`url` (Deprecated v2.12.2+, use `redisUrl` instead)
</Table.Cell>
<Table.Cell>
A string indicating the Redis connection URL.
</Table.Cell>
<Table.Cell>
No. If not provided, you must provide the `pubsub` option.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`redisUrl` (v2.12.2+)
</Table.Cell>
<Table.Cell>
A string indicating the Redis connection URL.
</Table.Cell>
<Table.Cell>
No. If not provided, you must provide the `pubsub` option.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`pubsub`
</Table.Cell>
<Table.Cell>
A connection object having the following properties:
- `url`: A required string indicating the Redis connection URL.
- `options`: An optional object of Redis options. Refer to the [Redis API Reference](https://redis.github.io/ioredis/index.html#RedisOptions) for details on accepted properties.
</Table.Cell>
<Table.Cell>
No. If not provided, you must provide the `url` option.
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`queueName`
</Table.Cell>
<Table.Cell>
The name of the queue used to keep track of retries and timeouts for workflow executions.
Default: `medusa-workflows`
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`jobQueueName`
</Table.Cell>
<Table.Cell>
The name of the queue used to keep track of retries and timeouts for scheduled jobs.
Default: `medusa-workflows-jobs`
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`options` (deprecated v2.12.2+, use `redisOptions` instead)
</Table.Cell>
<Table.Cell>
An object of Redis options. Refer to the [Redis API Reference](https://redis.github.io/ioredis/index.html#RedisOptions) for details on accepted properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`redisOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of Redis options. Refer to the [Redis API Reference](https://redis.github.io/ioredis/index.html#RedisOptions) for details on accepted properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`queueOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of options to pass to all BullMQ instances. Refer to [BullMQ's API reference](https://api.docs.bullmq.io/interfaces/v5.QueueOptions.html) for allowed properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`workerOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of options to pass to all BullMQ worker instances. Refer to [BullMQ's API reference](https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html) for allowed properties.
You can instead set options per worker using the `mainWorkerOptions`, `jobWorkerOptions`, and `cleanerWorkerOptions` options.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`mainQueueOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of options to pass to the main BullMQ queue instance for workflows. Refer to [BullMQ's API reference](https://api.docs.bullmq.io/interfaces/v5.QueueOptions.html) for allowed properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`mainWorkerOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of options to pass to the main BullMQ worker instance for workflows. Refer to [BullMQ's API reference](https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html) for allowed properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`jobQueueOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of options to pass to the main BullMQ workflow queue instance for scheduled jobs. Refer to [BullMQ's API reference](https://api.docs.bullmq.io/interfaces/v5.QueueOptions.html) for allowed properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`jobWorkerOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of options to pass to the main BullMQ workflow worker instance for scheduled jobs. Refer to [BullMQ's API reference](https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html) for allowed properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`cleanerQueueOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of options to pass to the BullMQ cleaner queue instance. Refer to [BullMQ's API reference](https://api.docs.bullmq.io/interfaces/v5.QueueOptions.html) for allowed properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
<Table.Row>
<Table.Cell>
`cleanerWorkerOptions` (v2.12.2+)
</Table.Cell>
<Table.Cell>
An object of options to pass to the BullMQ cleaner worker instance. Refer to [BullMQ's API reference](https://api.docs.bullmq.io/interfaces/v5.WorkerOptions.html) for allowed properties.
</Table.Cell>
<Table.Cell>
No
</Table.Cell>
</Table.Row>
</Table.Body>
</Table>To test the module, start the Medusa application:
npm run dev
You'll see the following message in the terminal's logs:
Connection to Redis in module 'workflow-engine-redis' established