# Introduction

## @nestjstools/messaging

```
npm install @nestjstools/messaging
or
yarn add @nestjstools/messaging
```

<figure><img src="/files/JEVspvJXM62VFYlJzjDr" alt=""><figcaption></figcaption></figure>

A NestJS library for managing asynchronous and synchronous messages (service bus) with support for buses, handlers, channels, and consumers. This library simplifies building scalable and decoupled applications by facilitating robust message handling pipelines while ensuring flexibility and reliability.

### Features

* **Message Buses**: Define multiple buses for commands, events, and queries to streamline message routing.
* **Handlers**: Easily register and manage handlers for processing messages.
* **Channels**: Support for in-memory channels and **easy extension** to create custom channel implementations tailored to your needs.
* **Consumers**: Run message consumers to process queued messages asynchronously, ensuring system reliability and fault tolerance.
* **Middleware Support**: Add custom middleware for message transformation such like validation, logging - do whatever you want.
* **Debug Mode**: Enable enhanced logging and debugging capabilities for development.
* **Extensibility**: Creating new channels is straightforward, allowing developers to expand and integrate with external systems or protocols effortlessly.
* **Concurrent Handler Execution**: Messages dispatched to multiple handlers are processed concurrently, improving performance and responsiveness across your system.

### Create an Event-driven app

<figure><img src="/files/yPowHhrqgTk3hXpHB6T6" alt=""><figcaption></figcaption></figure>

### Process logic in SYNC way in your handlers

<figure><img src="/files/q04bnCaU0FdHAuvKJkZn" alt=""><figcaption></figcaption></figure>

### Real-world app example

* <https://github.com/nestjstools/messaging-rabbitmq-example> - Messaging based on RabbitMQ + Redis
* <https://github.com/nestjstools/messaging-rabbitmq-example/tree/other-extensions> - All extensions

### Repositories

* <https://github.com/nestjstools/messaging>
* <https://github.com/nestjstools/messaging-bootstrap>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nestjstools.com/introduction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
