ServerRMQ

  
class ServerRMQ extends Server implements CustomTransportStrategy {
  constructor(options: { urls?: string[] | RmqUrl[]; queue?: string; prefetchCount?: number; isGlobalPrefetchCount?: boolean; queueOptions?: any; socketOptions?: any; noAck?: boolean; serializer?: Serializer<any, any>; ... 5 more ...; maxConnectionAttempts?: number; })
  transportId: Transport.RMQ
  protected server: any
  protected channel: any
  protected connectionAttempts: 0
  protected urls: string[] | RmqUrl[]
  protected queue: string
  protected prefetchCount: number
  protected queueOptions: any
  protected isGlobalPrefetchCount: boolean
  protected noAssert: boolean
  protected options: RmqOptions['options']
  listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void): Promise<void>
  close(): void
  start(callback?: (err?: unknown, ...optionalParams: unknown[]) => void)
  createClient<T = any>(): T
  setupChannel(channel: any, callback: Function)
  handleMessage(message: Record<string, any>, channel: any): Promise<void>
  sendMessage<T = any>(message: T, replyTo: any, correlationId: string): void
  protected initializeSerializer(options: { urls?: string[] | RmqUrl[]; queue?: string; prefetchCount?: number; isGlobalPrefetchCount?: boolean; queueOptions?: any; socketOptions?: any; noAck?: boolean; serializer?: Serializer<any, any>; ... 5 more ...; maxConnectionAttempts?: number; })

  // inherited from nest/packages/microservices/Server
  protected messageHandlers: Map<string, MessageHandler>
  protected logger: LoggerService
  protected serializer: ConsumerSerializer
  protected deserializer: ConsumerDeserializer
  addHandler(pattern: any, callback: MessageHandler<any, any, any>, isEventHandler: boolean = false, extras: Record<string, any> = {})
  getHandlers(): Map<string, MessageHandler>
  getHandlerByPattern(pattern: string): MessageHandler | null
  send(stream$: Observable<any>, respond: (data: WritePacket<any>) => unknown): Subscription
  handleEvent(pattern: string, packet: ReadPacket<any>, context: BaseRpcContext<unknown[]>): Promise<any>
  transformToObservable(resultOrDeferred: any)
  getOptionsProp<T extends MicroserviceOptions['options'], K extends keyof T>(obj: T, prop: K, defaultValue: T[K] = undefined)
  protected handleError(error: string)
  protected loadPackage<T = any>(name: string, ctx: string, loader?: Function): T
  protected initializeSerializer(options: { url?: string; maxSendMessageLength?: number; maxReceiveMessageLength?: number; maxMetadataSize?: number; keepalive?: { keepaliveTimeMs?: number; keepaliveTimeoutMs?: number; keepalivePermitWithoutCalls?: number; http2MaxPingsWithoutData?: number; http2MinTimeBetweenPingsMs?: number; http2MinPingIntervalWithoutData...)
  protected initializeDeserializer(options: { url?: string; maxSendMessageLength?: number; maxReceiveMessageLength?: number; maxMetadataSize?: number; keepalive?: { keepaliveTimeMs?: number; keepaliveTimeoutMs?: number; keepalivePermitWithoutCalls?: number; http2MaxPingsWithoutData?: number; http2MinTimeBetweenPingsMs?: number; http2MinPingIntervalWithoutData...)
  protected getRouteFromPattern(pattern: string): string
  protected normalizePattern(pattern: MsPattern): string
}

Constructor


constructor(options: { urls?: string[] | RmqUrl[]; queue?: string; prefetchCount?: number; isGlobalPrefetchCount?: boolean; queueOptions?: any; socketOptions?: any; noAck?: boolean; serializer?: Serializer<any, any>; ... 5 more ...; maxConnectionAttempts?: number; })

Parameters

Option Type Description
options object

Properties

Property Description
transportId: Transport.RMQ Read-only.
protected server: any
protected channel: any
protected connectionAttempts: 0
protected urls: string[] | RmqUrl[] Read-only.
protected queue: string Read-only.
protected prefetchCount: number Read-only.
protected queueOptions: any Read-only.
protected isGlobalPrefetchCount: boolean Read-only.
protected noAssert: boolean Read-only.
protected options: RmqOptions['options'] Read-only. Declared in constructor.

Methods

listen()


listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void): Promise<void>

Parameters

Option Type Description
callback (err?: unknown, ...optionalParams: unknown[]) => void

Returns

Promise<void>

close()


close(): void

Parameters

There are no parameters.

Returns

void

start()


start(callback?: (err?: unknown, ...optionalParams: unknown[]) => void)

Parameters

Option Type Description
callback (err?: unknown, ...optionalParams: unknown[]) => void

Optional. Default is undefined.

createClient()


createClient<T = any>(): T

Parameters

There are no parameters.

Returns

T

setupChannel()


setupChannel(channel: any, callback: Function)

Parameters

Option Type Description
channel any
callback Function

handleMessage()


handleMessage(message: Record<string, any>, channel: any): Promise<void>

Parameters

Option Type Description
message Record
channel any

Returns

Promise<void>

sendMessage()


sendMessage<T = any>(message: T, replyTo: any, correlationId: string): void

Parameters

Option Type Description
message T
replyTo any
correlationId string

Returns

void

initializeSerializer()


protected initializeSerializer(options: { urls?: string[] | RmqUrl[]; queue?: string; prefetchCount?: number; isGlobalPrefetchCount?: boolean; queueOptions?: any; socketOptions?: any; noAck?: boolean; serializer?: Serializer<any, any>; ... 5 more ...; maxConnectionAttempts?: number; })

Parameters

Option Type Description
options object