Configuration
Connection options and every configuration interface for @kubemq/nestjs-transport — KubeMQServerOptions, KubeMQClientOptions, and KubeMQCqrsOptions.
This page is the configuration lookup for @kubemq/nestjs-transport — package and runtime facts,
entry points, and every option interface for the server strategy, named clients, and the CQRS
bridge. For the decorator, context, and export surface see the API reference; for the
error catalog see error codes. For task-oriented setup, start with
Getting Started.
Package & Entry Points
@kubemq/nestjs-transport is the KubeMQ transport for NestJS microservices. It wires all five KubeMQ messaging patterns — Commands, Queries, Events, Events Store, and Queues — into the NestJS ecosystem with custom decorators, a dynamic module, health checks, a CQRS bridge, pluggable serialization, and testing utilities. It is built on the native kubemq-js SDK with a TypeScript-first API and an ESM + CJS dual build.
| Property | Value |
|---|---|
| Package | @kubemq/nestjs-transport |
| Runtime | Node.js >= 20.11.0 |
| NestJS | 10.x or 11.x |
| TypeScript | 5.5+ |
| Module format | ESM + CJS dual build (type: "module", main CJS, module ESM) |
| Runtime dependency | kubemq-js ^3.0.1 |
| License | MIT |
The package exposes three entry points through its exports map:
| Import path | Purpose |
|---|---|
@kubemq/nestjs-transport | Main entry — server, client, module, decorators, contexts, errors, serialization, constants |
@kubemq/nestjs-transport/testing | MockKubeMQClient and MockKubeMQServer for unit tests without a live broker |
@kubemq/nestjs-transport/cqrs | KubeMQCqrsModule and the @nestjs/cqrs bus bridge |
# Core transport + runtime SDK
npm install @kubemq/nestjs-transport kubemq-js
# Peer dependencies (most ship with a typical NestJS project)
npm install @nestjs/common @nestjs/core @nestjs/microservices rxjs reflect-metadata
# Optional peers — only for the features that use them
npm install @nestjs/terminus # health checks
npm install @nestjs/cqrs # CQRS bridge@nestjs/terminus, @nestjs/cqrs, @msgpack/msgpack, protobufjs, class-validator, class-transformer, and @opentelemetry/api are declared as optional peer dependencies. Install only the ones whose features you use — for example, @msgpack/msgpack is required by MessagePackSerializer, and class-validator / class-transformer are required by the decorator validate option.
The main entry point re-exports the testing mocks for convenience, so MockKubeMQClient and MockKubeMQServer are importable from either @kubemq/nestjs-transport or @kubemq/nestjs-transport/testing.
KubeMQServerOptions
Configuration for the KubeMQServer transport strategy you pass to connectMicroservice. KubeMQModuleOptions is this interface plus an isGlobal flag. Only address is required.
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
address | string | — | Yes | KubeMQ server address (host:port) |
clientId | string | Auto-generated | No | Unique client identifier |
credentials | string | undefined | No | Authentication token |
tls | TlsOptions | boolean | undefined | No | TLS configuration |
group | string | undefined | No | Default consumer group for all handlers |
defaultCommandTimeout | number | 10 | No | Default command timeout (seconds) |
defaultQueryTimeout | number | 10 | No | Default query timeout (seconds) |
eventsStore | { startFrom?, startValue? } | undefined | No | Events store defaults (startFrom is an EventStoreStartPosition) |
queue | { maxMessages?, waitTimeoutSeconds? } | undefined | No | Queue poll defaults |
serializer | KubeMQSerializer | JsonSerializer | No | Outbound message serializer |
deserializer | KubeMQDeserializer | JsonDeserializer | No | Inbound message deserializer |
waitForConnection | boolean | true | No | Block startup until connected |
callbackTimeoutSeconds | number | 30 | No | Handler callback timeout (seconds) |
retry | RetryPolicy | kubemq-js default | No | Retry policy for transient errors |
reconnect | ReconnectionPolicy | kubemq-js default | No | Reconnection policy |
keepalive | KeepaliveOptions | kubemq-js default | No | gRPC keepalive settings |
tracerProvider | unknown | undefined | No | OpenTelemetry tracer provider |
meterProvider | unknown | undefined | No | OpenTelemetry meter provider |
verboseErrors | boolean | false | No | Include raw broker messages in exceptions |
verboseHealth | boolean | false | No | Include detailed health data in checks |
validation | boolean | true | No | Enable/disable class-validator integration globally |
Timeout units. Fields ending in *Seconds (such as callbackTimeoutSeconds and waitTimeoutSeconds) are in seconds. The reconnection fields without that suffix (initialDelayMs, maxDelayMs) are in milliseconds.
KubeMQClientOptions
Configuration for a named KubeMQClientProxy created via register / registerAsync. It mirrors the server options for connection settings, and adds circuitBreaker, defaultQueuePolicy, and the internal channelPrefix set by forFeature.
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
address | string | — | Yes | KubeMQ server address (host:port) |
clientId | string | Auto-generated | No | Unique client identifier |
credentials | string | undefined | No | Authentication token |
tls | TlsOptions | boolean | undefined | No | TLS configuration |
defaultCommandTimeout | number | 10 | No | Default command timeout (seconds) |
defaultQueryTimeout | number | 10 | No | Default query timeout (seconds) |
serializer | KubeMQSerializer | JsonSerializer | No | Outbound message serializer |
deserializer | KubeMQDeserializer | JsonDeserializer | No | Inbound message deserializer |
defaultQueuePolicy | QueueMessagePolicyOptions | undefined | No | Default queue message policy |
retry | RetryPolicy | kubemq-js default | No | Retry policy for transient errors |
reconnect | ReconnectionPolicy | kubemq-js default | No | Reconnection policy |
keepalive | KeepaliveOptions | kubemq-js default | No | gRPC keepalive settings |
tracerProvider | unknown | undefined | No | OpenTelemetry tracer provider |
meterProvider | unknown | undefined | No | OpenTelemetry meter provider |
callbackTimeoutSeconds | number | 30 | No | Handler callback timeout (seconds) |
verboseErrors | boolean | false | No | Include raw broker messages in exceptions |
circuitBreaker | CircuitBreakerOptions | undefined | No | Circuit breaker wrapping client operations |
channelPrefix | string | undefined | No | Channel prefix prepended to all channels (set by forFeature) |
CircuitBreakerOptions
Prop
Type
QueueMessagePolicyOptions
Prop
Type
KubeMQCqrsOptions
Configuration for KubeMQCqrsModule.forRoot from @kubemq/nestjs-transport/cqrs. The bridge routes @nestjs/cqrs CommandBus, QueryBus, and EventBus traffic through KubeMQ channels named {prefix}.{MessageName}.
| Parameter | Type | Default | Description |
|---|---|---|---|
commandChannelPrefix | string | 'cqrs.commands' | Channel prefix for commands |
queryChannelPrefix | string | 'cqrs.queries' | Channel prefix for queries |
eventChannelPrefix | string | 'cqrs.events' | Channel prefix for events |
persistEvents | boolean | false | Use Events Store instead of Events for the EventBus |
commandTimeout | number | 10 | Command timeout (seconds) |
queryTimeout | number | 10 | Query timeout (seconds) |
drainTimeoutSeconds | number | 5 | Drain timeout on module destroy (seconds) |
channelResolver | (message: object) => string | message.constructor.name | Resolves the channel segment after the prefix |
serializer | KubeMQSerializer | JsonSerializer | Outbound message serializer |
deserializer | KubeMQDeserializer | JsonDeserializer | Inbound response deserializer |
import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { KubeMQModule } from '@kubemq/nestjs-transport';
import { KubeMQCqrsModule } from '@kubemq/nestjs-transport/cqrs';
@Module({
imports: [
KubeMQModule.forRoot({ address: 'localhost:50000' }),
CqrsModule,
KubeMQCqrsModule.forRoot({
commandChannelPrefix: 'myapp.commands',
queryChannelPrefix: 'myapp.queries',
eventChannelPrefix: 'myapp.events',
persistEvents: true,
commandTimeout: 10,
queryTimeout: 10,
}),
],
})
export class AppModule {}Import order matters: register KubeMQCqrsModule.forRoot() after both CqrsModule and KubeMQModule.forRoot(). The CQRS bridge relies on the connection that KubeMQModule.forRoot() provides.
See Also
Was this page helpful?