Interface ConsumerProps

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 exchangeBind

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 exchangeDeclare

exclusive?: boolean

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

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 queueBind

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 basicNack)

Default

true

Generated using TypeDoc