|
1
|
export const metadata = { |
|
2
|
title: `Local Event Module`, |
|
3
|
} |
|
4
|
|
|
5
|
# {metadata.title} |
|
6
|
|
|
7
|
The Local Event Module uses Node EventEmitter to implement Medusa's pub/sub events system. The Node EventEmitter is limited to a single process environment. |
|
8
|
|
|
9
|
This module is useful for development and testing, but it’s not recommended to be used in production. |
|
10
|
|
|
11
|
For production, it’s recommended to use modules like [Redis Event Bus Module](../redis/page.mdx). |
|
12
|
|
|
13
|
--- |
|
14
|
|
|
15
|
## Register the Local Event Module |
|
16
|
|
|
17
|
<Note> |
|
18
|
|
|
19
|
The Local Event Module is registered by default in your application. |
|
20
|
|
|
21
|
</Note> |
|
22
|
|
|
23
|
Add the module into the `modules` property of the exported object in `medusa-config.ts`: |
|
24
|
|
|
25
|
```ts title="medusa-config.ts" |
|
26
|
import { Modules } from "@medusajs/framework/utils" |
|
27
|
|
|
28
|
// ... |
|
29
|
|
|
30
|
module.exports = defineConfig({ |
|
31
|
// ... |
|
32
|
modules: [ |
|
33
|
{ |
|
34
|
resolve: "@medusajs/medusa/event-bus-local", |
|
35
|
}, |
|
36
|
], |
|
37
|
}) |
|
38
|
``` |
|
39
|
|
|
40
|
--- |
|
41
|
|
|
42
|
## Test the Module |
|
43
|
|
|
44
|
To test the module, start the Medusa application: |
|
45
|
|
|
46
|
```bash npm2yarn |
|
47
|
npm run dev |
|
48
|
``` |
|
49
|
|
|
50
|
You'll see the following message in the terminal's logs: |
|
51
|
|
|
52
|
```bash noCopy noReport |
|
53
|
Local Event Bus installed. This is not recommended for production. |
|
54
|
``` |