---
slug: /references/event-service
tags:
- event
- server
- how to
sidebar_label: Use Event Module
keywords:
- event
- provider
- integration
---
import { TypeList } from "docs-ui"
# How to Use Event Module
In this document, you’ll learn about the different methods in the Event Module's service and how to use them.
---
## Resolve Event Module's Service
In your workflow's step, you can resolve the Event Module's service from the Medusa container:
```ts
import { Modules } from "@medusajs/framework/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
const step1 = createStep(
"step-1",
async ({}, { container }) => {
const eventModuleService = container.resolve(
Modules.EVENT_BUS
)
// TODO use eventModuleService
}
)
```
This will resolve the service of the configured Event Module, which is the [Local Event Module](https://docs.medusajs.com/resources/infrastructure-modules/event/local) by default.
You can then use the Event Module's service's methods in the step. The rest of this guide details these methods.
---
## emit
This method emits one or more events. Subscribers listening to the event(s) are executed asynchronously.
### Example
```ts
await eventModuleService.emit({
name: "user.created",
data: {
user_id: "user_123"
}
})
```
### Type Parameters
### Parameters
`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"options","type":"`Record`","description":"Additional options for the event.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="emit"/>
### Returns
___
## subscribe
This method adds a subscriber to an event. It's mainly used internally to register subscribers.
### Example
```ts
eventModuleService.subscribe("user.created", async (data) => {
console.log("User created", data)
})
```
### Parameters
### Returns
___
## unsubscribe
This method removes a subscriber from an event. It's mainly used internally to unregister subscribers.
### Example
```ts
eventModuleService.unsubscribe("user.created", async (data) => {
console.log("User created", data)
})
```
### Parameters
### Returns
___
## releaseGroupedEvents
This method emits all events in the specified group. Grouped events are useful when you have distributed transactions
where you need to explicitly group, release and clear events upon lifecycle events of a transaction.
### Example
```ts
await eventModuleService.releaseGroupedEvents("group_123")
```
### Parameters
### Returns
___
## clearGroupedEvents
This method removes all events in the specified group. Grouped events are useful when you have distributed transactions
where you need to explicitly group, release and clear events upon lifecycle events of a transaction.
### Example
```ts
await eventModuleService.clearGroupedEvents("group_123")
```
### Parameters
### Returns
___
## addInterceptor
This method adds an interceptor to the event bus. This means that the interceptor will be
called before the event is emitted.
### Example
```ts
eventModuleService.addInterceptor((message, context) => {
console.log("Interceptor", message, context)
})
```
### Parameters
### Returns
___
## removeInterceptor
This method removes an interceptor from the event bus.
### Example
```ts
eventModuleService.removeInterceptor((message, context) => {
console.log("Interceptor", message, context)
})
```
### Parameters
### Returns