Represents an AMQP Channel. Almost all actions in AMQP are performed on a Channel.

Hierarchy

  • AMQPChannel

Constructors

Properties

closed: boolean = false
confirmId: number = 0
connection: AMQPBaseClient
consumers: Map<string, AMQPConsumer> = ...
delivery?: AMQPMessage
getMessage?: AMQPMessage
id: number
onerror: ((reason) => void)

Type declaration

    • (reason): void
    • Parameters

      • reason: string

      Returns void

returned?: AMQPMessage
rpcQueue: Promise<unknown> = ...
unconfirmedPublishes: [number, ((confirmId) => void), ((err?) => void)][] = []

Accessors

Methods

  • Acknowledge a delivered message

    Parameters

    • deliveryTag: number

      tag of the message

    • Optional multiple: boolean = false

      batch confirm all messages up to this delivery tag

    Returns Promise<void>

  • Consume from a queue. Messages will be delivered asynchronously.

    Parameters

    • queue: string

      name of the queue to poll

    • param: {
          args: undefined | {};
          exclusive: undefined | boolean;
          noAck: undefined | boolean;
          tag: undefined | string;
      } = {}
      • args: undefined | {}

        custom arguments

      • exclusive: undefined | boolean

        if this can be the only consumer of the queue, will return an Error if there are other consumers to the queue already

      • noAck: undefined | boolean

        if messages are removed from the server upon delivery, or have to be acknowledged

      • tag: undefined | string

        tag of the consumer, will be server generated if left empty

    • callback: ((msg) => void)

      will be called for each message delivered to this consumer

    Returns Promise<AMQPConsumer>

  • Enable or disable flow. Disabling flow will stop the server from delivering messages to consumers. Not supported in RabbitMQ

    Parameters

    • active: boolean = true

      false to stop the flow, true to accept messages

    Returns Promise<boolean>

  • Synchronously receive a message from a queue

    Parameters

    • queue: string

      name of the queue to poll

    • param: {
          noAck: undefined | boolean;
      } = {}
      • noAck: undefined | boolean

        if message is removed from the server upon delivery, or have to be acknowledged

    Returns Promise<null | AMQPMessage>

    • returns null if the queue is empty otherwise a single message
  • Acknowledge a delivered message

    Parameters

    • deliveryTag: number

      tag of the message

    • Optional requeue: boolean = false

      if the message should be requeued or removed

    • Optional multiple: boolean = false

      batch confirm all messages up to this delivery tag

    Returns Promise<void>

  • Publish a message

    Parameters

    • exchange: string

      the exchange to publish to, the exchange must exists

    • routingKey: string

      routing key

    • data: null | string | ArrayBuffer | Buffer | Uint8Array

      the data to be published, can be a string or an uint8array

    • properties: AMQPProperties = {}

      properties to be published

    • Optional mandatory: boolean = false

      if the message should be returned if there's no queue to be delivered to

    • Optional immediate: boolean = false

      if the message should be returned if it can't be delivered to a consumer immediately (not supported in RabbitMQ)

    Returns Promise<number>

    • fulfilled when the message is enqueue on the socket, or if publish confirm is enabled when the message is confirmed by the server
  • Set prefetch limit. Recommended to set as each unacknowledged message will be stored in memory of the client. The server won't deliver more messages than the limit until messages are acknowledged.

    Parameters

    • prefetchCount: number

      number of messages to limit to

    • prefetchSize: number = 0

      number of bytes to limit to (not supported by RabbitMQ)

    • global: boolean = false

      if the prefetch is limited to the channel, or if false to each consumer

    Returns Promise<void>

  • Tell the server to redeliver all unacknowledged messages again, or reject and requeue them.

    Parameters

    • Optional requeue: boolean = false

      if the message should be requeued or redeliviered to this channel

    Returns Promise<void>

  • Acknowledge a delivered message

    Parameters

    • deliveryTag: number

      tag of the message

    • Optional requeue: boolean = false

      if the message should be requeued or removed

    Returns Promise<void>

  • Close the channel gracefully

    Parameters

    • Optional reason: string = ""

      might be logged by the server

    • code: number = 200

    Returns Promise<void>

  • Enable publish confirm. The server will then confirm each publish with an Ack or Nack when the message is enqueued.

    Returns Promise<void>

  • Exchange to exchange binding.

    Parameters

    • destination: string

      name of the destination exchange

    • source: string

      name of the source exchange

    • routingKey: string = ""

      key to bind with

    • args: {} = {}

      optional arguments, e.g. for header exchanges

      Returns Promise<void>

      fulfilled when confirmed by the server

    • Declare an exchange

      Parameters

      • name: string

        name of the exchange

      • type: string

        type of exchange (direct, fanout, topic, header, or a custom type)

      • param: ExchangeParams = ...
      • args: {} = {}

        optional arguments

        Returns Promise<void>

        Fulfilled when the exchange is created or if it already exists

      • Delete an exchange

        Parameters

        • name: string

          name of the exchange

        • param: {
              ifUnused: undefined | boolean;
          } = {}
          • ifUnused: undefined | boolean

            only delete if the exchange doesn't have any bindings

        Returns Promise<void>

        Fulfilled when the exchange is deleted or if it's already deleted

      • Delete an exchange-to-exchange binding

        Parameters

        • destination: string

          name of destination exchange

        • source: string

          name of the source exchange

        • routingKey: string = ""

          key that was bound

        • args: {} = {}

          arguments, e.g. for header exchanges

          Returns Promise<void>

          fulfilled when confirmed by the server

        • Alias for basicQos

          Parameters

          • prefetchCount: number

            max inflight messages

          Returns Promise<void>

        • Bind a queue to an exchange

          Parameters

          • queue: string

            name of the queue

          • exchange: string

            name of the exchange

          • routingKey: string

            key to bind with

          • args: {} = {}

            optional arguments, e.g. for header exchanges

            Returns Promise<void>

            fulfilled when confirmed by the server

          • Declare a queue

            Parameters

            • name: string = ""

              name of the queue, if empty the server will generate a name

            • params: QueueParams = ...
            • args: {} = {}

              optional custom queue arguments

              Returns Promise<QueueOk>

              fulfilled when confirmed by the server

            • Delete a queue

              Parameters

              • name: string = ""

                name of the queue, if empty it will delete the last declared queue

              • params: {
                    ifEmpty: undefined | boolean;
                    ifUnused: undefined | boolean;
                } = {}
                • ifEmpty: undefined | boolean

                  only delete if the queue is empty

                • ifUnused: undefined | boolean

                  only delete if the queue doesn't have any consumers

              Returns Promise<MessageCount>

            • Unbind a queue from an exchange

              Parameters

              • queue: string

                name of the queue

              • exchange: string

                name of the exchange

              • routingKey: string

                key that was bound

              • args: {} = {}

                arguments, e.g. for header exchanges

                Returns Promise<void>

                fulfilled when confirmed by the server

              • Returns Promise<never>

                Rejected promise with an error

              • Send a RPC request, will resolve a RPC promise when RPC response arrives

                Parameters

                • frame: AMQPView

                  with data

                • frameSize: number

                  bytes the frame actually is

                Returns Promise<any>

              • Parameters

                • methodId: number

                Returns Promise<void>

              • Set this channel in Transaction mode. Rember to commit the transaction, overwise the server will eventually run out of memory.

                Returns Promise<void>

              Generated using TypeDoc