@cloudamqp/amqp-client
    Preparing search index...

    Class AMQPQueue<P, C, KP, KC>

    High-level queue handle returned by AMQPSession#queue.

    All operations are reconnect-safe: they acquire a session channel on each call, so they work transparently after a reconnection. subscribe provides automatic consumer recovery. publish waits for a broker confirm; use Pass { confirm: false } to skip the wait.

    Type Parameters

    • P extends ParserMap = {}
    • C extends CoderMap = {}
    • KP extends keyof P & string = never
    • KC extends keyof C & string = never
    Index

    Properties

    name: string

    Queue name.

    Methods

    • Wait for a single message, then cancel the underlying consumer. Pairs with get (zero-wait poll) and subscribe (long-lived):

      • get() — is there a message right now? null otherwise.
      • consumeOne({ timeout }) — wait up to N ms for one message.
      • subscribe(cb) — keep delivering until cancelled.

      Throws when timeout elapses with no delivery — distinct from get()'s null return, so callers can't conflate "nothing" with "deadline missed".

      The library acks the delivered message before resolving and uses wire-level noAck: false with prefetch: 1 so the broker holds the queue at a single in-flight delivery; messages beyond the one returned stay in the queue for the next consumer.

      Parameters

      • options: { timeout?: number } = {}
        • Optionaltimeout?: number

          max wait in milliseconds (omit to wait forever)

      Returns Promise<AMQPMessage<P>>

    • Delete this queue.

      Parameters

      • Optionalparams: { ifEmpty?: boolean; ifUnused?: boolean }
        • OptionalifEmpty?: boolean

          only delete if the queue is empty

        • OptionalifUnused?: boolean

          only delete if the queue has no consumers

      Returns Promise<MessageCount>

    • Poll the queue for a single message.

      Parameters

      • Optionalparams: { noAck?: boolean }
        • OptionalnoAck?: boolean

          automatically acknowledge on delivery

      Returns Promise<null | AMQPMessage<P>>

    • Publish a message directly to this queue (via the default exchange).

      When the session has parsers configured, body can be any value accepted by the matching parser's serialize method. Without parsers, body must be a string, Buffer, Uint8Array, or null.

      Defaults: confirm: true, deliveryMode: 2 (persistent). Pass deliveryMode: 1 to send a transient message.

      Type Parameters

      • O extends string = KP

      Parameters

      Returns Promise<AMQPQueue<P, C, KP, KC>>

      this for chaining