npm.io
2.22.7 • Published 4d ago

@medusajs/event-bus-redis

Licence
MIT
Version
2.22.7
Deps
2
Size
51 kB
Vulns
0
Weekly
0
Stars
36.8K

Medusa logo

@medusajs/event-bus-redis

Documentation | Website

Building blocks for digital commerce

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

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. {}

Resources