Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RabbitMQPublisher

A reliable publisher that

  • Queues up messages internally until it can successfully call basicPublish.
  • Notifies the caller using a robust ID (not delivery tag) when the message is confirmed by rabbit.

This is a layer above the RabbitMQClient that provides a lot of standard implementation when guaranteed at least once delivery is required. If confirmations are not required do not use this publisher as it does have overhead.

Hierarchy

  • RabbitMQPublisher

Index

Methods

getConfirmationStream

  • Get the ReadStream that contains the message IDs for confirmed messages. The message IDs in this ReadStream are taken from the message properties, if these message IDs are not set then this ReadStream will contain nulls and using this publisher will be pointless.

    Returns ReadStream<RabbitMQPublisherConfirmation>

publish

  • publish(exchange: string, routingKey: string, properties: any, body: Buffer): PromiseLike<void>
  • publish(exchange: string, routingKey: string, properties: any, body: Buffer, resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): void
  • Publish a message.

    Parameters

    • exchange: string
    • routingKey: string
    • properties: any
    • body: Buffer

    Returns PromiseLike<void>

  • Publish a message.

    Parameters

    • exchange: string
    • routingKey: string
    • properties: any
    • body: Buffer
    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns void

queueSize

  • queueSize(): number
  • Get the number of published, but not sent, messages.

    Returns number

restart

  • restart(): void
  • Undo the effects of calling {@link RabbitMQPublisher#stop} so that publish may be called again. It is harmless to call restart() when {@link RabbitMQPublisher#stop} has not been called, however if restart() is called whilst {@link RabbitMQPublisher#stop} is being processed the {@link RabbitMQPublisher#stop} will never complete.

    Returns void

start

  • start(): PromiseLike<void>
  • start(resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): void
  • Start the rabbitMQ publisher. The RabbitMQClient should have been started before this.

    Returns PromiseLike<void>

  • Start the rabbitMQ publisher. The RabbitMQClient should have been started before this.

    Parameters

    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns void

stop

  • stop(): PromiseLike<void>
  • stop(resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): void
  • Stop the rabbitMQ publisher. Calling this is optional, but it gives the opportunity to drain the send queue without losing messages. Future calls to publish will be ignored.

    Returns PromiseLike<void>

  • Stop the rabbitMQ publisher. Calling this is optional, but it gives the opportunity to drain the send queue without losing messages. Future calls to publish will be ignored.

    Parameters

    • resultHandler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns void

Static create

Generated using TypeDoc