@medusajs/event-bus-redis
Documentation | Website
Building blocks for digital commerce
Redis Event Bus Module for Medusa: a production-ready event bus that queues events and runs subscribers with BullMQ on top of Redis. Use it in production instead of the default local event bus, especially when running multiple Medusa instances or separate server and worker processes. It ships with @medusajs/medusa and is registered as @medusajs/medusa/event-bus-redis.
At a glance
| Package | @medusajs/event-bus-redis |
| Type | Infrastructure Module |
| Module key | Modules.EVENT_BUS ("event_bus") |
| Registered by default | No (registered automatically on Medusa Cloud when REDIS_URL is set) |
Installation
No installation needed. The module ships with @medusajs/medusa. You need a running Redis server.
Usage
Register the module in medusa-config.ts:
import { defineConfig } from "@medusajs/framework/utils"
module.exports = defineConfig({
// ...
modules: [
{
resolve: "@medusajs/medusa/event-bus-redis",
options: {
redisUrl: process.env.EVENTS_REDIS_URL,
},
},
],
})
Configuration
| Option | Type | Description | Default |
|---|---|---|---|
redisUrl |
string |
Redis connection URL. Required: the module throws on startup without it. | - |
redisOptions |
RedisOptions |
ioredis client options, merged into the connection options. | {} |
queueName |
string |
Name of the BullMQ queue. | "events-queue" |
queueOptions |
Omit<QueueOptions, "connection"> |
BullMQ queue options. | {} |
workerOptions |
Omit<WorkerOptions, "connection"> |
BullMQ worker options, such as concurrency. |
{} |
jobOptions |
JobsOptions |
Default BullMQ job options applied to every emitted event, such as removeOnComplete and removeOnFail. Options passed to emit override them. |
{} |