Interface ConsumerProps

interface ConsumerProps {
    arguments?: {
        x-cancel-on-ha-failover?: boolean;
        x-priority?: number;
        [k: string]: any;
    };
    concurrency?: number;
    consumerTag?: string;
    exchangeBindings?: {
        arguments?: Record<string, any>;
        destination: string;
        routingKey?: string;
        source: string;
    }[];
    exchanges?: {
        arguments?: {
            alternate-exchange?: string;
            [k: string]: any;
        };
        autoDelete?: boolean;
        durable?: boolean;
        exchange: string;
        internal?: boolean;
        passive?: boolean;
        type?: string;
    }[];
    exclusive?: boolean;
    lazy?: boolean;
    noAck?: boolean;
    noLocal?: boolean;
    qos?: {
        global?: boolean;
        prefetchCount?: number;
        prefetchSize?: number;
    };
    queue?: string;
    queueBindings?: {
        arguments?: Record<string, any>;
        exchange: string;
        queue?: string;
        routingKey?: string;
    }[];
    queueOptions?: {
        arguments?: {
            x-dead-letter-exchange?: string;
            x-dead-letter-routing-key?: string;
            x-expires?: number;
            x-max-length?: number;
            x-max-priority?: number;
            x-message-ttl?: number;
            x-overflow?: "drop-head" | "reject-publish" | "reject-publish-dlx";
            x-queue-type?: "quorum" | "classic" | "stream";
            [k: string]: any;
        };
        autoDelete?: boolean;
        durable?: boolean;
        exclusive?: boolean;
        passive?: boolean;
        queue?: string;
    };
    requeue?: boolean;
}

Hierarchy

  • BasicConsumeParams
    • ConsumerProps

Properties

arguments?: {
    x-cancel-on-ha-failover?: boolean;
    x-priority?: number;
    [k: string]: any;
}

Type declaration

concurrency?: number

Non-zero positive integer. Maximum number of messages to process at once. Should be less than or equal to "qos.prefetchCount". Any prefetched, but unworked, messages will be requeued when the underlying channel is closed (unless noAck=true, when every received message will be processed).

Default

Infinity
consumerTag?: string

Specifies the identifier for the consumer. The consumer tag is local to a channel, so two clients can use the same consumer tags. If this field is empty the server will generate a unique tag.

exchangeBindings?: {
    arguments?: Record<string, any>;
    destination: string;
    routingKey?: string;
    source: string;
}[]

Any exchange-exchange bindings to be declared before the consumer and whenever the connection is reset. See Channel.exchangeBind

Type declaration

  • Optional arguments?: Record<string, any>

    A set of arguments for the binding. The syntax and semantics of these arguments depends on the exchange class.

  • destination: string

    Specifies the name of the destination exchange to bind.

  • Optional routingKey?: string

    Specifies the routing key for the binding. The routing key is used for routing messages depending on the exchange configuration. Not all exchanges use a routing key - refer to the specific exchange documentation.

  • source: string

    Specifies the name of the source exchange to bind.

exchanges?: {
    arguments?: {
        alternate-exchange?: string;
        [k: string]: any;
    };
    autoDelete?: boolean;
    durable?: boolean;
    exchange: string;
    internal?: boolean;
    passive?: boolean;
    type?: string;
}[]

Any exchanges to be declared before the consumer and whenever the connection is reset. See Channel.exchangeDeclare

Type declaration

  • Optional arguments?: {
        alternate-exchange?: string;
        [k: string]: any;
    }
  • Optional autoDelete?: boolean

    If set, the exchange is deleted when all queues have finished using it.

  • Optional durable?: boolean

    If set when creating a new exchange, the exchange will be marked as durable. Durable exchanges remain active when a server restarts. Non-durable exchanges (transient exchanges) are purged if/when a server restarts.

  • exchange: string

    Exchange names starting with "amq." are reserved for pre-declared and standardised exchanges. The exchange name consists of a non-empty sequence of these characters: letters, digits, hyphen, underscore, period, or colon.

  • Optional internal?: boolean

    If set, the exchange may not be used directly by publishers, but only when bound to other exchanges. Internal exchanges are used to construct wiring that is not visible to applications.

  • Optional passive?: boolean

    If set, the server will reply with Declare-Ok if the exchange already exists with the same name, and raise an error if not. The client can use this to check whether an exchange exists without modifying the server state. When set, all other method fields except name and no-wait are ignored. A declare with both passive and no-wait has no effect. Arguments are compared for semantic equivalence.

  • Optional type?: string

    direct, topic, fanout, or headers: Each exchange belongs to one of a set of exchange types implemented by the server. The exchange types define the functionality of the exchange - i.e. how messages are routed through it.

    Default

    "direct"
    
exclusive?: boolean

Request exclusive consumer access, meaning only this consumer can access the queue.

lazy?: boolean

If true, the consumer will not automatically start. You must call consumer.start() yourself.

Default

false
noAck?: boolean

If this field is set the server does not expect acknowledgements for messages. That is, when a message is delivered to the client the server assumes the delivery will succeed and immediately dequeues it. This functionality may increase performance but at the cost of reliability. Messages can get lost if a client dies before they are delivered to the application.

noLocal?: boolean

If the no-local field is set the server will not send messages to the connection that published them.

qos?: {
    global?: boolean;
    prefetchCount?: number;
    prefetchSize?: number;
}

If defined, basicQos() is invoked just before creating the consumer and whenever the connection is reset

Type declaration

  • Optional global?: boolean

    RabbitMQ has reinterpreted this field. The original specification said: "By default the QoS settings apply to the current channel only. If this field is set, they are applied to the entire connection." Instead, RabbitMQ takes global=false to mean that the QoS settings should apply per-consumer (for new consumers on the channel; existing ones being unaffected) and global=true to mean that the QoS settings should apply per-channel.

  • Optional prefetchCount?: number

    Specifies a prefetch window in terms of whole messages. This field may be used in combination with the prefetch-size field; a message will only be sent in advance if both prefetch windows (and those at the channel and connection level) allow it. The prefetch-count is ignored if the no-ack option is set.

  • Optional prefetchSize?: number

    The client can request that messages be sent in advance so that when the client finishes processing a message, the following message is already held locally, rather than needing to be sent down the channel. Prefetching gives a performance improvement. This field specifies the prefetch window size in octets. The server will send a message in advance if it is equal to or smaller in size than the available prefetch size (and also falls into other prefetch limits). May be set to zero, meaning "no specific limit", although other prefetch limits may still apply. The prefetch-size is ignored if the no-ack option is set.

queue?: string

Specifies the name of the queue to consume from. If blank then the last declared queue (on the channel) will be used.

queueBindings?: {
    arguments?: Record<string, any>;
    exchange: string;
    queue?: string;
    routingKey?: string;
}[]

Any queue-exchange bindings to be declared before the consumer and whenever the connection is reset. See Channel.queueBind

Type declaration

  • Optional arguments?: Record<string, any>
  • exchange: string

    Name of the exchange to bind to.

  • Optional queue?: string

    Specifies the name of the queue to bind. If blank, then the last declared queue on the channel will be used.

  • Optional routingKey?: string

    Specifies the routing key for the binding. The routing key is used for routing messages depending on the exchange configuration. Not all exchanges use a routing key - refer to the specific exchange documentation. If the queue name is empty, the server uses the last queue declared on the channel. If the routing key is also empty, the server uses this queue name for the routing key as well. If the queue name is provided but the routing key is empty, the server does the binding with that empty routing key. The meaning of empty routing keys depends on the exchange implementation.

queueOptions?: {
    arguments?: {
        x-dead-letter-exchange?: string;
        x-dead-letter-routing-key?: string;
        x-expires?: number;
        x-max-length?: number;
        x-max-priority?: number;
        x-message-ttl?: number;
        x-overflow?: "drop-head" | "reject-publish" | "reject-publish-dlx";
        x-queue-type?: "quorum" | "classic" | "stream";
        [k: string]: any;
    };
    autoDelete?: boolean;
    durable?: boolean;
    exclusive?: boolean;
    passive?: boolean;
    queue?: string;
}

Additional options when declaring the queue just before creating the consumer and whenever the connection is reset.

Type declaration

  • Optional arguments?: {
        x-dead-letter-exchange?: string;
        x-dead-letter-routing-key?: string;
        x-expires?: number;
        x-max-length?: number;
        x-max-priority?: number;
        x-message-ttl?: number;
        x-overflow?: "drop-head" | "reject-publish" | "reject-publish-dlx";
        x-queue-type?: "quorum" | "classic" | "stream";
        [k: string]: any;
    }
  • Optional autoDelete?: boolean

    If set, the queue is deleted when all consumers have finished using it. The last consumer can be cancelled either explicitly or because its channel is closed. If there was no consumer ever on the queue, it won't be deleted. Applications can explicitly delete auto-delete queues using the Delete method as normal.

  • Optional durable?: boolean

    If set when creating a new queue, the queue will be marked as durable. Durable queues remain active when a server restarts. Non-durable queues (transient queues) are purged if/when a server restarts. Note that durable queues do not necessarily hold persistent messages, although it does not make sense to send persistent messages to a transient queue.

  • Optional exclusive?: boolean

    Exclusive queues may only be accessed by the current connection, and are deleted when that connection closes. Passive declaration of an exclusive queue by other connections are not allowed.

  • Optional passive?: boolean

    If set, the server will reply with Declare-Ok if the queue already exists with the same name, and raise an error if not. The client can use this to check whether a queue exists without modifying the server state. When set, all other method fields except name and no-wait are ignored. A declare with both passive and no-wait has no effect.

  • Optional queue?: string

    The queue name MAY be empty, in which case the server MUST create a new queue with a unique generated name and return this to the client in the Declare-Ok method. Queue names starting with "amq." are reserved for pre-declared and standardised queues. The queue name can be empty, or a sequence of these characters: letters, digits, hyphen, underscore, period, or colon.

requeue?: boolean

Requeue message when the handler throws an Error (as with Channel.basicNack)

Default

true

Generated using TypeDoc