---
url: https://node-ts.github.io/bus/api/bus-core/interfaces/CustomHandler.md
---
[API reference](../../index.md) / [@node-ts/bus-core](../index.md) / CustomHandler

# Interface: CustomHandler\<TMessage>

Defined in: [packages/bus-core/src/handler/custom-handler.ts:7](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-core/src/handler/custom-handler.ts#L7)

A handler that handles messages defined externally to the system, that don't extend from the Message base

## Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
| `TMessage` | `any` |

## Methods

### handle()

```ts
handle(
   message, 
   attributes, 
   context
): unknown;
```

Defined in: [packages/bus-core/src/handler/custom-handler.ts:15](https://github.com/node-ts/bus/blob/2e6cf65c27833b707ae31ee623cfb6343770f434/packages/bus-core/src/handler/custom-handler.ts#L15)

Called each time a message that this handler's resolver matches is received

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `message` | `TMessage` | The message read from the bus |
| `attributes` | [`MessageAttributes`](../../bus-messages/interfaces/MessageAttributes.md) | Attributes of the message read from the bus |
| `context` | [`HandlerContext`](HandlerContext.md) | Sends, publishes, fails or returns messages through the bus that received the message |

#### Returns

`unknown`

Anything. A returned promise is awaited, and the value it resolves to is ignored
