prorm API Reference
    Preparing search index...

    Class RabbitMQStore

    RabbitMQStore wraps a single amqplib channel and exposes RabbitMQ's core AMQP operations: asserting queues/exchanges, binding them, publishing (to a queue directly or via an exchange), consuming with ack/nack, and consumer prefetch (QoS).

    Implements

    Index
    name: "rabbitmq" = 'rabbitmq'

    The name of the store (e.g. 'mongodb', 'redis', 'dynamodb')

    library: "amqplib" = 'amqplib'

    The client library being used

    • Declare a queue, creating it if it doesn't exist (idempotent). Returns amqplib's assertion reply ({ queue, messageCount, consumerCount }). Pass '' as queue to have the broker generate a unique name.

      Parameters

      • queue: string
      • Optionaloptions: any

      Returns Promise<any>

    • Declare an exchange of the given type ('direct', 'fanout', 'topic', 'headers'), creating it if it doesn't exist (idempotent).

      Parameters

      • exchange: string
      • type: string
      • Optionaloptions: any

      Returns Promise<any>

    • Bind queue to exchange so messages published to exchange matching pattern (the routing/binding key) are routed into queue.

      Parameters

      • queue: string
      • exchange: string
      • pattern: string

      Returns Promise<any>

    • Send a message straight to a named queue (via the default exchange). Non-Buffer messages are serialized — strings UTF-8 encoded, other values JSON.stringify'd (see the module docs). Returns amqplib's boolean write result (false when the channel's write buffer is full and you should wait for a 'drain' event before writing more).

      Parameters

      • queue: string
      • message: unknown
      • Optionaloptions: any

      Returns Promise<boolean>

    • Publish a message to an exchange with a routingKey; the exchange routes it to bound queues. Non-Buffer messages are serialized like sendToQueue(). Returns amqplib's boolean write result.

      Parameters

      • exchange: string
      • routingKey: string
      • message: unknown
      • Optionaloptions: any

      Returns Promise<boolean>

    • Register handler to receive each message delivered from queue. The handler is called with the raw amqplib message object (or null if the consumer is cancelled by the broker); decode msg.content yourself. Unless options.noAck is set, call ack(msg)/nack(msg) when done. Returns amqplib's { consumerTag } reply.

      Parameters

      • queue: string
      • handler: (msg: any) => void
      • Optionaloptions: any

      Returns Promise<any>

    • Acknowledge a delivered message so the broker can drop it.

      Parameters

      • message: any
      • OptionalallUpTo: boolean

      Returns void

    • Reject a delivered message. By default RabbitMQ requeues it (requeue defaults to true in amqplib); pass requeue = false to drop or dead-letter it.

      Parameters

      • message: any
      • OptionalallUpTo: boolean
      • Optionalrequeue: boolean

      Returns void

    • Set the consumer prefetch (QoS) — the max number of unacknowledged messages the broker will deliver to consumers on this channel at once.

      Parameters

      • count: number
      • Optionalglobal: boolean

      Returns Promise<any>