KubeMQ
IntegrationsNestJSReference

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.

PropertyValue
Package@kubemq/nestjs-transport
RuntimeNode.js >= 20.11.0
NestJS10.x or 11.x
TypeScript5.5+
Module formatESM + CJS dual build (type: "module", main CJS, module ESM)
Runtime dependencykubemq-js ^3.0.1
LicenseMIT

The package exposes three entry points through its exports map:

Import pathPurpose
@kubemq/nestjs-transportMain entry — server, client, module, decorators, contexts, errors, serialization, constants
@kubemq/nestjs-transport/testingMockKubeMQClient and MockKubeMQServer for unit tests without a live broker
@kubemq/nestjs-transport/cqrsKubeMQCqrsModule and the @nestjs/cqrs bus bridge
install.sh
# 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.

ParameterTypeDefaultRequiredDescription
addressstringYesKubeMQ server address (host:port)
clientIdstringAuto-generatedNoUnique client identifier
credentialsstringundefinedNoAuthentication token
tlsTlsOptions | booleanundefinedNoTLS configuration
groupstringundefinedNoDefault consumer group for all handlers
defaultCommandTimeoutnumber10NoDefault command timeout (seconds)
defaultQueryTimeoutnumber10NoDefault query timeout (seconds)
eventsStore{ startFrom?, startValue? }undefinedNoEvents store defaults (startFrom is an EventStoreStartPosition)
queue{ maxMessages?, waitTimeoutSeconds? }undefinedNoQueue poll defaults
serializerKubeMQSerializerJsonSerializerNoOutbound message serializer
deserializerKubeMQDeserializerJsonDeserializerNoInbound message deserializer
waitForConnectionbooleantrueNoBlock startup until connected
callbackTimeoutSecondsnumber30NoHandler callback timeout (seconds)
retryRetryPolicykubemq-js defaultNoRetry policy for transient errors
reconnectReconnectionPolicykubemq-js defaultNoReconnection policy
keepaliveKeepaliveOptionskubemq-js defaultNogRPC keepalive settings
tracerProviderunknownundefinedNoOpenTelemetry tracer provider
meterProviderunknownundefinedNoOpenTelemetry meter provider
verboseErrorsbooleanfalseNoInclude raw broker messages in exceptions
verboseHealthbooleanfalseNoInclude detailed health data in checks
validationbooleantrueNoEnable/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.

ParameterTypeDefaultRequiredDescription
addressstringYesKubeMQ server address (host:port)
clientIdstringAuto-generatedNoUnique client identifier
credentialsstringundefinedNoAuthentication token
tlsTlsOptions | booleanundefinedNoTLS configuration
defaultCommandTimeoutnumber10NoDefault command timeout (seconds)
defaultQueryTimeoutnumber10NoDefault query timeout (seconds)
serializerKubeMQSerializerJsonSerializerNoOutbound message serializer
deserializerKubeMQDeserializerJsonDeserializerNoInbound message deserializer
defaultQueuePolicyQueueMessagePolicyOptionsundefinedNoDefault queue message policy
retryRetryPolicykubemq-js defaultNoRetry policy for transient errors
reconnectReconnectionPolicykubemq-js defaultNoReconnection policy
keepaliveKeepaliveOptionskubemq-js defaultNogRPC keepalive settings
tracerProviderunknownundefinedNoOpenTelemetry tracer provider
meterProviderunknownundefinedNoOpenTelemetry meter provider
callbackTimeoutSecondsnumber30NoHandler callback timeout (seconds)
verboseErrorsbooleanfalseNoInclude raw broker messages in exceptions
circuitBreakerCircuitBreakerOptionsundefinedNoCircuit breaker wrapping client operations
channelPrefixstringundefinedNoChannel 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}.

ParameterTypeDefaultDescription
commandChannelPrefixstring'cqrs.commands'Channel prefix for commands
queryChannelPrefixstring'cqrs.queries'Channel prefix for queries
eventChannelPrefixstring'cqrs.events'Channel prefix for events
persistEventsbooleanfalseUse Events Store instead of Events for the EventBus
commandTimeoutnumber10Command timeout (seconds)
queryTimeoutnumber10Query timeout (seconds)
drainTimeoutSecondsnumber5Drain timeout on module destroy (seconds)
channelResolver(message: object) => stringmessage.constructor.nameResolves the channel segment after the prefix
serializerKubeMQSerializerJsonSerializerOutbound message serializer
deserializerKubeMQDeserializerJsonDeserializerInbound response deserializer
cqrs.module.ts
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?

On this page