KubeMQ
IntegrationsNestJS

NestJS

A custom NestJS transport wiring all five KubeMQ messaging patterns into the microservices ecosystem with idiomatic decorators, a CQRS bridge, and DI.

@kubemq/nestjs-transport is a custom NestJS transport that integrates KubeMQ into the NestJS microservices ecosystem. It surfaces all five KubeMQ messaging patterns — Commands, Queries, Events, Events Store, and Queues — through idiomatic @*Handler decorators and a standard ClientProxy, so a Nest app sends and handles KubeMQ messages with the same DI, modules, and testing patterns it already uses for HTTP. It is built on the native kubemq-js SDK and speaks gRPC directly to the broker on port 50000.

Why KubeMQ + NestJS

  • Idiomatic decorators@CommandHandler, @QueryHandler, @EventHandler, @EventStoreHandler, and @QueueHandler replace manual @MessagePattern / @EventPattern metadata wiring; the right KubeMQ pattern is attached for you.
  • One transport, five patterns — a single KubeMQServer strategy (inbound) and KubeMQClientProxy (outbound) cover every pattern; the KubeMQRecord builder re-targets the message type with .asQuery(), .asEventStore(), or .asQueue().
  • Dynamic-module DIforRoot / forRootAsync / register / registerAsync / forFeature / forTest register the connection and named clients through NestJS dependency injection.
  • Distributed CQRS — the CQRS bridge routes @nestjs/cqrs CommandBus, QueryBus, and EventBus traffic across services over KubeMQ channels.
  • TypeScript-first — full type safety with an ESM + CJS dual build and per-pattern context types.
  • Broker-free testsMockKubeMQClient, MockKubeMQServer, and KubeMQModule.forTest() exercise services and handlers without a live broker.

Installation

npm install @kubemq/nestjs-transport kubemq-js

Most peer dependencies already ship with a typical NestJS project; install any that are missing:

npm install @nestjs/common @nestjs/core @nestjs/microservices rxjs reflect-metadata

Optional peer dependencies enable specific features — @nestjs/terminus for the health-check indicator and @nestjs/cqrs for the CQRS bridge:

npm install @nestjs/terminus   # health checks
npm install @nestjs/cqrs        # CQRS bridge

Prerequisites: Node.js 20.11.0 or later and a running KubeMQ broker (default localhost:50000). The transport is a native gRPC SDK client — there is no connector flag to enable; the gRPC API on 50000 is always on. Start a local broker with Docker (gRPC on 50000, the shared HTTP server and dashboard on 9090):

docker run -d \  --name kubemq \  -p 50000:50000 \  -p 9090:9090 \  -e KUBEMQ_TOKEN=YOUR_LICENSE_KEY \  europe-docker.pkg.dev/kubemq/images/kubemq:next

Supported versions

RequirementSupported versions
LanguageTypeScript 5.5+ (ESM + CJS dual build)
RuntimeNode.js >= 20.11.0
NestJS10.x or 11.x
KubeMQ SDKkubemq-js ^3.0.1
Package@kubemq/nestjs-transport 1.0.0

Architecture

A KubeMQ-backed NestJS app is a hybrid application: the HTTP app stays as-is while the KubeMQ transport is attached as a microservice. Inbound handlers run through the KubeMQServer strategy passed to app.connectMicroservice({ strategy }); outbound clients are KubeMQClientProxy instances registered with KubeMQModule. Both wrap a kubemq-js client and speak gRPC to the broker on port 50000.

Decorated handlers and injected client proxies both wrap kubemq-js and reach the broker over native gRPC.

Capabilities

The transport plugs into NestJS DI and dispatch. Each capability below documents the integration's own API surface and links to the underlying KubeMQ concept rather than re-teaching it.

CapabilitySurfaceKubeMQ concept
Commands / Queries@CommandHandler / @QueryHandler, client.send()RPC
Events@EventHandler, client.emit()Events
Events Store@EventStoreHandler, .asEventStore()Events Store
Queues@QueueHandler, .asQueue(), manual ackQueues
Module DIforRoot / register / forFeature / forTest
Distributed CQRSKubeMQCqrsModule over @nestjs/cqrs buses

Next steps

New to integrations? See what an integration is for the mental model, or start with the KubeMQ Getting Started guide for core broker concepts. This transport speaks native gRPC on port 50000 — it is a direct SDK client, not a connector.

Was this page helpful?

On this page