{"id":28436108,"url":"https://github.com/nestjstools/messaging","last_synced_at":"2026-03-14T16:26:47.783Z","repository":{"id":274351411,"uuid":"922642227","full_name":"nestjstools/messaging","owner":"nestjstools","description":"Simplifies asynchronous and synchronous message handling with support for buses, handlers, channels, and consumers. Build scalable, decoupled applications with ease and reliability.","archived":false,"fork":false,"pushed_at":"2026-03-13T23:36:03.000Z","size":513,"stargazers_count":34,"open_issues_count":3,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-14T10:37:54.919Z","etag":null,"topics":["cqrs","distributed-systems","message-bus","messaging","microservices","nestjs","nestjs-messaging","nestjs-service-bus","nestjstools","nodejs","service-bus"],"latest_commit_sha":null,"homepage":"https://docs.nestjstools.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nestjstools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-26T18:32:00.000Z","updated_at":"2026-03-08T15:04:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"08091e62-c960-486a-8775-4a126ff6c500","html_url":"https://github.com/nestjstools/messaging","commit_stats":null,"previous_names":["nestjstools/messaging"],"tags_count":54,"template":false,"template_full_name":null,"purl":"pkg:github/nestjstools/messaging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjstools%2Fmessaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjstools%2Fmessaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjstools%2Fmessaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjstools%2Fmessaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nestjstools","download_url":"https://codeload.github.com/nestjstools/messaging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjstools%2Fmessaging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30508858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-14T14:51:43.155Z","status":"ssl_error","status_checked_at":"2026-03-14T14:47:41.964Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cqrs","distributed-systems","message-bus","messaging","microservices","nestjs","nestjs-messaging","nestjs-service-bus","nestjstools","nodejs","service-bus"],"created_at":"2025-06-05T21:10:04.982Z","updated_at":"2026-03-14T16:26:47.778Z","avatar_url":"https://github.com/nestjstools.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"nestjstools-logo.png\" width=\"400\" alt=\"NestJS Messaging Library\"\u003e\n\u003c/p\u003e\n\n# NestJS Messaging Library – Message Bus \u0026 Service Bus for Distributed Systems\n\nA powerful **message bus and service bus library for NestJS** designed for building **scalable, event-driven and distributed systems**.\n\nNestJSTools Messaging provides a **broker-independent messaging abstraction** that allows applications to communicate through **commands, events and queries** using a flexible **message bus architecture**.\n\nThe framework integrates seamlessly with the **NestJS dependency injection system**, decorators and modules, making it easy to build **CQRS architectures, microservices and event-driven applications**.\n\nIt supports multiple messaging transports including **RabbitMQ, Redis, NATS, Amazon SQS, Google Pub/Sub and Azure Service Bus**, allowing developers to switch brokers without rewriting application logic.\n\nThis repository contains the **core messaging framework** and **official transport extensions** for integrating different messaging infrastructures.\n\n![npm](https://img.shields.io/npm/v/@nestjstools/messaging)\n![npm downloads](https://img.shields.io/npm/dm/@nestjstools/messaging)\n![license](https://img.shields.io/npm/l/@nestjstools/messaging)\n\n---\n\n## Features of NestJSTools Messaging\n\nNestJSTools Messaging helps you build **scalable, event-driven and distributed systems in NestJS** without coupling your application to a specific messaging broker.\n\nKey capabilities include:\n\n- **Message Bus architecture** (Commands, Events, Queries)\n- **Broker-independent messaging** – easily switch transports\n- **Multiple handlers per message**\n- **Channel abstraction layer**\n- **Middleware pipeline for message processing**\n- **Custom message normalization (serialization / deserialization)**\n- **Async consumers for background message processing**\n- **Centralized exception handling**\n- **Custom logging support**\n- **High extensibility for building custom transports**\n\nSupported transports include:\n\n- RabbitMQ\n- Redis\n- NATS\n- Amazon SQS\n- Google Pub/Sub\n- Azure Service Bus\n\n---\n\n## Packages\n\n### Core\n\n| Package                                                                          | Description              |\n|----------------------------------------------------------------------------------|--------------------------|\n| [`@nestjstools/messaging`](https://www.npmjs.com/package/@nestjstools/messaging) | Core messaging framework |\n\n### Official Extensions\n\n| Package                                                                                                                                  | Description               |\n|------------------------------------------------------------------------------------------------------------------------------------------|---------------------------|\n| [`@nestjstools/messaging-redis-extension`](https://www.npmjs.com/package/@nestjstools/messaging-redis-extension)                         | Redis channel adapter     |\n| [`@nestjstools/messaging-rabbitmq-extension`](https://www.npmjs.com/package/@nestjstools/messaging-rabbitmq-extension)                   | RabbitMQ channel adapter  |\n| [`@nestjstools/messaging-amazon-sqs-extension`](https://www.npmjs.com/package/@nestjstools/messaging-amazon-sqs-extension)               | Amazon SQS adapter        |\n| [`@nestjstools/messaging-google-pubsub-extension`](https://www.npmjs.com/package/@nestjstools/messaging-google-pubsub-extension)         | Google Pub/Sub adapter    |\n| [`@nestjstools/messaging-nats-extension`](https://www.npmjs.com/package/@nestjstools/messaging-nats-extension)                           | NATS adapter              |\n| [`@nestjstools/messaging-azure-service-bus-extension`](https://www.npmjs.com/package/@nestjstools/messaging-azure-service-bus-extension) | Azure Service Bus adapter |\n\n---\n\n## Installation\n\nInstall the **core package**:\n\n```bash\nnpm install @nestjstools/messaging\n````\n\nor\n\n```bash\nyarn add @nestjstools/messaging\n```\n\nThen install a **transport extension** if needed:\n\n```bash\nnpm install @nestjstools/messaging-rabbitmq-extension\n```\n\n---\n\n## Quick Example\n\nBelow is a minimal example showing how to:\n\n* define a **message**\n* create a **message handler**\n* configure the **MessagingModule**\n* **dispatch a message**\n\n---\n\n### 1️⃣ Define a Message\n\n```ts\nexport class SendMessage {\n  constructor(\n    public readonly content: string,\n  ) {\n  }\n}\n```\n\n### 2️⃣ Create a Message Handler\n\n```ts\nimport { Injectable } from '@nestjs/common';\nimport {\n  MessageHandler,\n  IMessageHandler,\n} from '@nestjstools/messaging';\nimport { SendMessage } from './send-message';\n\n@Injectable()\n@MessageHandler('chat.message')\nexport class SendMessageHandler implements IMessageHandler\u003cSendMessage\u003e {\n\n  async handle(message: SendMessage): Promise\u003cvoid\u003e {\n    console.log('Received message:', message.content);\n  }\n\n}\n```\n\n### 3️⃣ Configure the Messaging Module\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { MessagingModule, InMemoryChannelConfig } from '@nestjstools/messaging';\nimport { SendMessageHandler } from './send-message.handler';\n\n@Module({\n  imports: [\n    MessagingModule.forRoot({\n      buses: [\n        {\n          name: 'message.bus',\n          channels: ['memory'],\n        },\n      ],\n      channels: [\n        new InMemoryChannelConfig({\n          name: 'memory',\n        }),\n      ],\n      debug: true,\n    }),\n  ],\n  providers: [SendMessageHandler],\n})\nexport class AppModule {\n}\n```\n\n### 4️⃣ Dispatch a Message\n\nMessages can be dispatched from **anywhere in your application**.\n\nExample using a controller:\n\n```ts\nimport { Controller, Get } from '@nestjs/common';\nimport { IMessageBus, MessageBus, RoutingMessage } from '@nestjstools/messaging';\nimport { SendMessage } from './send-message';\n\n@Controller()\nexport class AppController {\n\n  constructor(\n    @MessageBus('message.bus')\n    private readonly messageBus: IMessageBus,\n  ) {\n  }\n\n  @Get()\n  async send(): Promise\u003cstring\u003e {\n\n    await this.messageBus.dispatch(\n      new RoutingMessage(\n        new SendMessage('Hello from NestJSTools!'),\n        'chat.message',\n      ),\n    );\n\n    return 'Message dispatched!';\n  }\n}\n```\n\n---\n## Architecture\n\n### High level flow of message dispatching and handling:\n\n```mermaid\nflowchart LR\n\n    M[Message]\n    MB[Message Bus]\n    C[(Channel)]\n    MW[Middleware]\n    H[Message Handler]\n\n    M --\u003e|dispatch| MB\n    MB --\u003e C\n    C --\u003e MW\n    MW --\u003e H\n```\n\n### Exception handling flow:\n\n```mermaid\nflowchart LR\n\n    M[Message]\n    MB[MessageBus]\n    C[InMemoryChannel]\n    MW[Middleware]\n    H[MessageHandler]\n    EL[ExceptionListener]\n\n    M --\u003e|dispatch| MB\n    MB --\u003e C\n    C --\u003e MW\n    MW --\u003e H\n\n    H -. throws error .-\u003e C\n    MW -. throws error .-\u003e C\n    C -. notify .-\u003e EL\n```\n\n---\n\n## Links\n\n* Official documentation: [https://docs.nestjstools.com/messaging](https://docs.nestjstools.com/messaging)\n* Website: [https://nestjstools.com](https://nestjstools.com)\n* RabbitMQ example: [https://github.com/nestjstools/messaging-rabbitmq-example](https://github.com/nestjstools/messaging-rabbitmq-example)\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome!\n\nPlease open an issue or pull request if you want to:\n\n* add a new transport\n* improve documentation\n* fix bugs\n* propose new features\n\n---\n\n## ⭐ Support\n\nIf you like this project please **star the repository** ⭐\nIt helps the project grow and reach more developers.\n\n## Keywords\n\nnestjs messaging library  \nnestjs message bus  \nnestjs service bus  \nnestjs event bus  \nnestjs distributed systems  \nnestjs microservices messaging  \nbroker independent messaging for nestjs  \nnestjs rabbitmq abstraction  \nnestjs redis messaging  \nnestjs nats messaging\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjstools%2Fmessaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnestjstools%2Fmessaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjstools%2Fmessaging/lists"}