ServerRMQ

  
class ServerRMQ extends Server {
  constructor(options: { urls?: string[] | RmqUrl[]; queue?: string; prefetchCount?: number; isGlobalPrefetchCount?: boolean; queueOptions?: AmqplibQueueOptions; socketOptions?: AmqpConnectionManagerSocketOptions; ... 10 more ...; maxConnectionAttempts?: number; })
  transportId: Transport.RMQ
  protected server: AmqpConnectionManager
  protected channel: ChannelWrapper
  protected connectionAttempts: 0
  protected urls: string[] | RmqUrl[]
  protected queue: string
  protected noAck: boolean
  protected queueOptions: any
  protected pendingEventListeners: Array<{...}
  protected options: Required<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>
  handleEvent(pattern: string, packet: ReadPacket<any>, context: RmqContext): Promise<any>
  sendMessage<T = any>(message: T, replyTo: any, correlationId: string): void
  unwrap<T>(): T
  on<EventKey extends keyof RmqEvents = keyof RmqEvents, EventCallback extends RmqEvents[EventKey] = RmqEvents[EventKey]>(event: EventKey, callback: EventCallback)
  protected initializeSerializer(options: { urls?: string[] | RmqUrl[]; queue?: string; prefetchCount?: number; isGlobalPrefetchCount?: boolean; queueOptions?: AmqplibQueueOptions; socketOptions?: AmqpConnectionManagerSocketOptions; ... 10 more ...; maxConnectionAttempts?: number; })

  // inherited from nest/packages/microservices/Server
  transportId?: Transport | symbol
  protected messageHandlers: Map<string, MessageHandler>
  protected logger: LoggerService
  protected serializer: ConsumerSerializer
  protected deserializer: ConsumerDeserializer
  protected _status$: ReplaySubject<Status>
  status: Observable<Status>
  abstract on<EventKey extends keyof EventsMap = keyof EventsMap, EventCallback extends EventsMap[EventKey] = EventsMap[EventKey]>(event: EventKey, callback: EventCallback): any
  abstract unwrap<T>(): T
  abstract listen(callback: (...optionalParams: unknown[]) => any): any
  abstract close(): any
  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>) => void | Promise<unknown>): Subscription
  handleEvent(pattern: string, packet: ReadPacket<any>, context: BaseRpcContext<unknown[]>): Promise<any>
  transformToObservable(resultOrDeferred: any)
  getOptionsProp<Options extends MicroserviceOptions['options'], Attribute extends keyof Options, DefaultValue extends Options[Attribute] = Options[Attribute]>(obj: Options, prop: Attribute, defaultValue: DefaultValue = undefined as DefaultValue)
  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?: AmqplibQueueOptions; socketOptions?: AmqpConnectionManagerSocketOptions; ... 10 more ...; maxConnectionAttempts?: number; })

Parameters

Option Type Description
options object

Properties

Property Description
transportId: Transport.RMQ Read-only.
protected server: AmqpConnectionManager
protected channel: ChannelWrapper
protected connectionAttempts: 0
protected urls: string[] | RmqUrl[] Read-only.
protected queue: string Read-only.
protected noAck: boolean Read-only.
protected queueOptions: any Read-only.
protected pendingEventListeners: Array<{ event: keyof RmqEvents; callback: RmqEvents[keyof RmqEvents]; }>
protected options: Required<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>

handleEvent()


handleEvent(pattern: string, packet: ReadPacket<any>, context: RmqContext): Promise<any>

Parameters

Option Type Description
pattern string
packet ReadPacket
context RmqContext

Returns

Promise<any>

sendMessage()


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

Parameters

Option Type Description
message T
replyTo any
correlationId string

Returns

void

unwrap()


unwrap<T>(): T

Parameters

There are no parameters.

Returns

T

on()


on<EventKey extends keyof RmqEvents = keyof RmqEvents, EventCallback extends RmqEvents[EventKey] = RmqEvents[EventKey]>(event: EventKey, callback: EventCallback)

Parameters

Option Type Description
event EventKey
callback EventCallback

initializeSerializer()


protected initializeSerializer(options: { urls?: string[] | RmqUrl[]; queue?: string; prefetchCount?: number; isGlobalPrefetchCount?: boolean; queueOptions?: AmqplibQueueOptions; socketOptions?: AmqpConnectionManagerSocketOptions; ... 10 more ...; maxConnectionAttempts?: number; })

Parameters

Option Type Description
options object