An instance of a Queue which is connected to either a regular amqplib.Channel or a amqplib.ConfirmChannel.

Hierarchy

  • Queue

Constructors

  • Creates an instance of a Queue which is connected to either a regular amqplib.Channel or a amqplib.ConfirmChannel.

    Parameters

    • name: string

      The name of the queue.

    • client: Connection

      The connection client.

    • channel: ConnectionChannel

      The connection channel.

    • type: "confirm" | "basic"

      The type of the channel.

    • Optional instrumentors: Partial<QueueInstrumentors>

      Optional instrumentors for the queue.

    Returns Queue

Accessors

  • get name(): string
  • Returns the name of the queue.

    Returns string

    • The name of the queue.

Methods

  • Removes the specified event listener for the 'error' event.

    Parameters

    • event: "error"

      The name of the event to remove the listener from ('error').

    • listener: QueueErrorEventListener

      The function to remove as a listener for the 'error' event.

    Returns void

  • Removes the specified event listener for the 'deleted' event.

    Parameters

    • event: "deleted"

      The name of the event to remove the listener from ('deleted').

    • listener: QueueDeletedEventListener

      The function to remove as a listener for the 'deleted' event.

    Returns void

  • Removes the specified event listener for the 'message' event.

    Parameters

    • event: "message"

      The name of the event to remove the listener from ('message').

    • listener: QueueMessageListener

      The function to remove as a listener for the 'message' event.

    Returns void

  • Registers an event listener for the 'error' event.

    Parameters

    • event: "error"

      The name of the event to listen for ('error').

    • listener: QueueErrorEventListener

      The function to invoke when the 'error' event is emitted.

    Returns void

  • Registers an event listener for the 'deleted' event.

    Parameters

    • event: "deleted"

      The name of the event to listen for ('deleted').

    • listener: QueueDeletedEventListener

      The function to invoke when the 'deleted' event is emitted.

    Returns void

  • Registers an event listener for the 'message' event.

    Parameters

    • event: "message"

      The name of the event to listen for ('message').

    • listener: QueueMessageListener

      The function to invoke when the 'message' event is emitted.

    Returns void

  • Registers a one-time event listener for the 'error' event. The listener will be invoked at most once for the event, and then removed.

    Parameters

    • event: "error"

      The name of the event to listen for ('error').

    • listener: QueueErrorEventListener

      The function to invoke when the 'error' event is emitted.

    Returns void

  • Registers a one-time event listener for the 'deleted' event. The listener will be invoked at most once for the event, and then removed.

    Parameters

    • event: "deleted"

      The name of the event to listen for ('deleted').

    • listener: QueueDeletedEventListener

      The function to invoke when the 'deleted' event is emitted.

    Returns void

  • Registers a one-time event listener for the 'message' event. The listener will be invoked at most once for the event, and then removed.

    Parameters

    • event: "message"

      The name of the event to listen for ('message').

    • listener: QueueMessageListener

      The function to invoke when the 'message' event is emitted.

    Returns void

  • Acknowledges a message, indicating that it has been successfully processed and can be removed from the queue.

    Parameters

    • message: QueueMessage

      The message to acknowledge.

    • Optional allUpTo: boolean

      Whether to acknowledge all messages up to and including the given message.

    Returns void

  • Wait for all ack and nack confirmations to be transmitted to the server, or timeout after a specified amount of time.

    Parameters

    • timeout: number = 10000

      The amount of time to wait for confirmations to process before timing out.

    Returns Promise<void>

    Since

    1.0.11

  • Wait for all pending RPC messages to be processed, or timeout after a specified amount of time.

    Parameters

    • timeout: number = 10000

      The amount of time to wait for pending RPC messages to process before timing out.

    Returns Promise<void>

    Since

    1.0.12

  • Checks the queue for messages and returns the number of messages in the queue.

    Returns Promise<AssertQueue>

    • A promise that resolves with the result of checking the queue.
  • Consumes messages from the queue as quickly as possible, invoking the given listener function for each message received.

    Parameters

    • Optional listener: QueueMessageListener

      The function to invoke for each message received.

    • Optional options: Partial<QueueConsumptionOptions>

      The options to use when consuming messages.

    • Optional abortSignal: AbortSignal

      An optional abort signal that can be used to cancel the listener.

    • priority: number = 1
    • additional: Record<string, any> = {}

    Returns Promise<void>

    • A promise that resolves when the listener has been stopped.

    Throws

    • Throws an error if noAck, ackOnNoAck, and nackOnNoAck are all false.
  • Deletes the queue with the given options.

    Parameters

    • Optional options: Partial<DeleteQueue>

      The options to use when deleting the queue.

    Returns Promise<DeleteQueue>

    • A promise that resolves with the result of deleting the queue.
  • Enqueues a message to the queue with the given content and options.

    Parameters

    • content: Buffer

      The content of the message to enqueue.

    • Optional options: Partial<QueueEnqueueOptions>

      The options to use when enqueuing the message.

    Returns Promise<boolean>

    • A promise that resolves with a boolean indicating whether the message was successfully enqueued.
  • Retrieves a message from the queue with the given options.

    Parameters

    • Optional options: Partial<GetMessagesOptions>

      The options to use when retrieving the message.

    Returns Promise<false | QueueMessage>

    • A promise that resolves with the retrieved message or false if no message is available.
  • Listens for messages on the queue, invoking the given listener function for each message received.

    Parameters

    • Optional listener: QueueMessageListener

      The function to invoke for each message received.

    • Optional options: Partial<QueueListeningOptions>

      The options to use when listening for messages.

    • Optional abortSignal: AbortSignal

      An optional abort signal that can be used to cancel the listener.

    Returns Promise<void>

    • A promise that resolves when the listener has been started.

    Since

    1.0.16

    Throws

    • Throws an error if noAck, ackOnNoAck, and nackOnNoAck are all false.
  • Rejects a message, indicating that it has not been successfully processed and should be requeued or discarded.

    Parameters

    • message: QueueMessage

      The message to reject.

    • Optional requeue: boolean = true

      Whether to requeue the message or discard it.

    • Optional allUpTo: boolean = false

      Whether to reject all messages up to and including the given message.

    Returns void

  • Pauses the queue listener, preventing it from processing any new messages until resumed. If the queue is already paused, this method does nothing.

    Parameters

    • Optional timeout: number = 1000

      The number of milliseconds to wait for the queue to finish processing confirmations before timing out.

    Returns Promise<void>

    • A promise that resolves when the queue has been successfully paused.

    Since

    1.0.10

  • Purges the queue, removing all messages from it.

    Returns Promise<PurgeQueue>

    • A promise that resolves with the result of purging the queue.