Redis Event Module

The Redis Event Module uses Redis to implement Medusa's pub/sub events system.

It's powered by BullMQ and io-redis. BullMQ is responsible for the message queue and worker, and io-redis is the underlying Redis client that BullMQ connects to for events storage.

In production, it's recommended to use this module.

Using Cloud? Our Cloud offering automatically provisions a Redis instance and configures the Redis Event Module for you. Learn more in the Redis Cloud documentation.

Register the Redis Event Module#

Add the module into the modules property of the exported object in medusa-config.ts:

medusa-config.ts
1import { Modules } from "@medusajs/framework/utils"2
3// ...4
5module.exports = defineConfig({6  // ...7  modules: [8    {9      resolve: "@medusajs/medusa/event-bus-redis",10      options: { 11        redisUrl: process.env.EVENTS_REDIS_URL,12      },13    },14  ],15})

Environment Variables#

Make sure to add the following environment variables:

Terminal
EVENTS_REDIS_URL=<YOUR_REDIS_URL>

Redis Event Module Options#

OptionDescriptionRequiredDefault

redisUrl

A string indicating the Redis connection URL.

Yes

-

redisOptions

An object of Redis options. Refer to the Redis API Reference for details on accepted properties.

No

-

queueName

A string indicating BullMQ's queue name.

No

events-queue

queueOptions

An object of options to pass to the BullMQ constructor. Refer to BullMQ's API reference for allowed properties.

No

-

workerOptions

An object of options to pass to the BullMQ Worker constructor. Refer to BullMQ's API reference for allowed properties.

No

-

jobOptions

An object of options to pass to jobs added to the BullMQ queue. Refer to BullMQ's API reference for allowed properties.

No

-

Test the Module#

To test the module, start the Medusa application:

You'll see the following message in the terminal's logs:

Terminal
Connection to Redis in module 'event-redis' established
Was this page helpful?
Ask Anything
Ask any questions about Medusa. Get help with your development.
You can also use the Medusa MCP server in Cursor, VSCode, etc...
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break