UNPKG

rabbitmq-client

Version:
472 lines (471 loc) 21.6 kB
/** @ignore */ export declare enum Cmd { ExchangeDeclare = 2621450, ExchangeDeclareOK = 2621451, ExchangeDelete = 2621460, ExchangeDeleteOK = 2621461, ExchangeBind = 2621470, ExchangeBindOK = 2621471, ExchangeUnbind = 2621480, ExchangeUnbindOK = 2621491, QueueDeclare = 3276810, QueueDeclareOK = 3276811, QueueBind = 3276820, QueueBindOK = 3276821, QueuePurge = 3276830, QueuePurgeOK = 3276831, QueueDelete = 3276840, QueueDeleteOK = 3276841, QueueUnbind = 3276850, QueueUnbindOK = 3276851, BasicQos = 3932170, BasicQosOK = 3932171, BasicConsume = 3932180, BasicConsumeOK = 3932181, BasicCancel = 3932190, BasicCancelOK = 3932191, BasicPublish = 3932200, BasicReturn = 3932210, BasicDeliver = 3932220, BasicGet = 3932230, BasicGetOK = 3932231, BasicGetEmpty = 3932232, BasicAck = 3932240, BasicReject = 3932250, BasicRecover = 3932270, BasicRecoverOK = 3932271, BasicNack = 3932280, ConfirmSelect = 5570570, ConfirmSelectOK = 5570571, TxSelect = 5898250, TxSelectOK = 5898251, TxCommit = 5898260, TxCommitOK = 5898261, TxRollback = 5898270, TxRollbackOK = 5898271 } /** @ignore */ export interface MethodParams { [Cmd.BasicAck]: { /** The server-assigned and channel-specific delivery tag */ deliveryTag?: number; /** If set to 1, the delivery tag is treated as "up to and including", so * that multiple messages can be acknowledged with a single method. If set * to zero, the delivery tag refers to a single message. If the multiple * field is 1, and the delivery tag is zero, this indicates acknowledgement * of all outstanding messages. */ multiple?: boolean; }; [Cmd.BasicCancel]: { consumerTag: string; }; [Cmd.BasicCancelOK]: { consumerTag: string; }; [Cmd.BasicConsume]: { arguments?: { /** https://www.rabbitmq.com/consumer-priority.html */ 'x-priority'?: number; /** https://www.rabbitmq.com/ha.html#cancellation */ 'x-cancel-on-ha-failover'?: boolean; [k: string]: any; }; /** 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. */ consumerTag?: string; /** Request exclusive consumer access, meaning only this consumer can * access the queue. */ exclusive?: 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. */ noAck?: boolean; /** If the no-local field is set the server will not send messages to the * connection that published them. */ noLocal?: boolean; /** Specifies the name of the queue to consume from. If blank then the last * declared queue (on the channel) will be used.*/ queue?: string; }; [Cmd.BasicConsumeOK]: { consumerTag: string; }; [Cmd.BasicDeliver]: { /** Identifier for the consumer, valid within the current channel. */ consumerTag: string; /** The server-assigned and channel-specific delivery tag */ deliveryTag: number; /** Specifies the name of the exchange that the message was originally * published to. May be empty, indicating the default exchange. */ exchange: string; /** True if the message has been previously delivered to this or another * client. */ redelivered: boolean; /** The routing key name specified when the message was published. */ routingKey: string; }; [Cmd.BasicGet]: { /** Specifies the name of the queue to consume from. */ queue?: string; /** 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. */ noAck?: boolean; }; [Cmd.BasicGetEmpty]: void; [Cmd.BasicGetOK]: { /** The server-assigned and channel-specific delivery tag */ deliveryTag: number; /** True if the message has been previously delivered to this or another * client. */ redelivered: boolean; /** The name of the exchange that the message was originally published to. * May be empty, indicating the default exchange. */ exchange: string; /** The routing key name specified when the message was published. */ routingKey: string; /** Number of messages remaining in the queue */ messageCount: number; }; [Cmd.BasicNack]: { deliveryTag?: number; /** If set to 1, the delivery tag is treated as "up to and including", so * that multiple messages can be rejected with a single method. If set to * zero, the delivery tag refers to a single message. If the multiple field * is 1, and the delivery tag is zero, this indicates rejection of all * outstanding messages. */ multiple?: boolean; /** If requeue is true, the server will attempt to requeue * the message. If requeue is false or the requeue attempt fails the * messages are discarded or dead-lettered. The default should be TRUE, * according to the AMQP specification, however this can lead to an endless * retry-loop if you're not careful. Messages consumed from a {@link * https://www.rabbitmq.com/quorum-queues.html#poison-message-handling | * quorum queue} will have the "x-delivery-count" header, allowing you to * discard a message after too many attempted deliveries. For classic * mirrored queues, or non-mirrored queues, you will need to construct your * own mechanism for discarding poison messages. * @default true */ requeue?: boolean; }; [Cmd.BasicPublish]: { /** Specifies the name of the exchange to publish to. The exchange name can * be empty, meaning the default exchange. If the exchange name is * specified, and that exchange does not exist, the server will raise a * channel exception. */ exchange?: string; /** This flag tells the server how to react if the message cannot be routed * to a queue consumer immediately. If this flag is set, the server will * return an undeliverable message with a Return method. If this flag is * zero, the server will queue the message, but with no guarantee that it * will ever be consumed. */ immediate?: string; /** This flag tells the server how to react if the message cannot be routed * to a queue. If this flag is set, the server will return an unroutable * message with a Return method. If this flag is zero, the server silently * drops the message. */ mandatory?: boolean; /** Specifies the routing key for the message. The routing key is used for * routing messages depending on the exchange configuration. */ routingKey?: string; }; [Cmd.BasicQos]: { /** 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. */ prefetchSize?: 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. */ prefetchCount?: number; /** 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. */ global?: boolean; }; [Cmd.BasicQosOK]: void; [Cmd.BasicRecover]: { /** If this field is zero, the message will be redelivered to the original * recipient. If this bit is 1, the server will attempt to requeue the * message, potentially then delivering it to an alternative subscriber. */ requeue?: boolean; }; [Cmd.BasicRecoverOK]: void; [Cmd.BasicReject]: { deliveryTag: number; requeue?: boolean; }; [Cmd.BasicReturn]: { replyCode: number; replyText: string; exchange: string; routingKey: string; }; [Cmd.ConfirmSelect]: { nowait?: boolean; }; [Cmd.ConfirmSelectOK]: void; [Cmd.ExchangeBind]: { /** Specifies the name of the destination exchange to bind. */ destination: string; /** Specifies the name of the source exchange to bind. */ source: 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. */ routingKey?: string; /** A set of arguments for the binding. The syntax and semantics of these * arguments depends on the exchange class. */ arguments?: Record<string, any>; }; [Cmd.ExchangeBindOK]: void; [Cmd.ExchangeDeclare]: { arguments?: { /** https://www.rabbitmq.com/ae.html */ 'alternate-exchange'?: string; [k: string]: any; }; /** If set, the exchange is deleted when all queues have finished using it. */ autoDelete?: 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. */ durable?: boolean; /** 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. */ exchange: string; /** 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. */ internal?: 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. */ passive?: boolean; /** 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" */ type?: string; }; [Cmd.ExchangeDeclareOK]: void; [Cmd.ExchangeDelete]: { /** Name of the exchange */ exchange: string; /** If set, the server will only delete the exchange if it has no queue * bindings. If the exchange has queue bindings the server does not delete * it but raises a channel exception instead. */ ifUnused?: boolean; }; [Cmd.ExchangeDeleteOK]: void; [Cmd.ExchangeUnbind]: { arguments?: Record<string, any>; /** Specifies the name of the destination exchange to unbind. */ destination: string; /** Specifies the routing key of the binding to unbind. */ routingKey?: string; /** Specifies the name of the source exchange to unbind. */ source: string; }; [Cmd.ExchangeUnbindOK]: void; [Cmd.QueueBind]: { arguments?: Record<string, any>; /** Name of the exchange to bind to. */ exchange: string; /** Specifies the name of the queue to bind. If blank, then the last * declared queue on the channel will be used. */ queue?: 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. */ routingKey?: string; }; [Cmd.QueueBindOK]: void; [Cmd.QueueDeclare]: { arguments?: { /** Per-Queue Message TTL https://www.rabbitmq.com/ttl.html#per-queue-message-ttl */ 'x-message-ttl'?: number; /** Queue Expiry https://www.rabbitmq.com/ttl.html#queue-ttl */ 'x-expires'?: number; /** https://www.rabbitmq.com/dlx.html */ 'x-dead-letter-exchange'?: string; /** https://www.rabbitmq.com/dlx.html */ 'x-dead-letter-routing-key'?: string; /** https://www.rabbitmq.com/maxlength.html */ 'x-max-length'?: number; /** https://www.rabbitmq.com/maxlength.html */ 'x-overflow'?: 'drop-head' | 'reject-publish' | 'reject-publish-dlx'; /** https://www.rabbitmq.com/priority.html */ 'x-max-priority'?: number; /** https://www.rabbitmq.com/quorum-queues.html * https://www.rabbitmq.com/streams.html */ 'x-queue-type'?: 'quorum' | 'classic' | 'stream'; [k: string]: any; }; /** 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. */ autoDelete?: 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. */ durable?: 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. */ exclusive?: 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. */ passive?: boolean; /** 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. */ queue?: string; }; [Cmd.QueueDeclareOK]: { queue: string; messageCount: number; consumerCount: number; }; [Cmd.QueueDelete]: { /** If set, the server will only delete the queue if it has no messages. */ ifEmpty?: boolean; /** If set, the server will only delete the queue if it has no consumers. * If the queue has consumers the server does does not delete it but raises * a channel exception instead. */ ifUnused?: boolean; /** Specifies the name of the queue to delete. */ queue?: string; }; [Cmd.QueueDeleteOK]: { messageCount: number; }; [Cmd.QueuePurge]: { queue?: string; }; [Cmd.QueuePurgeOK]: { messageCount: number; }; [Cmd.QueueUnbind]: { arguments?: Record<string, any>; /** The name of the exchange to unbind from. */ exchange: string; /** Specifies the name of the queue to unbind. */ queue?: string; /** Specifies the routing key of the binding to unbind. */ routingKey?: string; }; [Cmd.QueueUnbindOK]: void; [Cmd.TxCommit]: void; [Cmd.TxCommitOK]: void; [Cmd.TxRollback]: void; [Cmd.TxRollbackOK]: void; [Cmd.TxSelect]: void; [Cmd.TxSelectOK]: void; } export interface HeaderFields { /** MIME content type. e.g. "application/json" */ contentType?: string; /** MIME content encoding. e.g. "gzip" */ contentEncoding?: string; /** Additional user-defined fields */ headers?: { /** https://www.rabbitmq.com/sender-selected.html */ 'CC'?: string[]; /** https://www.rabbitmq.com/sender-selected.html */ 'BCC'?: string[]; [k: string]: any; }; /** Alias for "deliveryMode". Published message should be saved to * disk and should survive server restarts. */ durable?: boolean; /** Message priority, 0 to 9. */ priority?: number; /** Application correlation identifier. */ correlationId?: string; /** https://www.rabbitmq.com/direct-reply-to.html */ replyTo?: string; /** Message TTL, in milliseconds. Note that only when expired messages reach * the head of a queue will they actually be discarded (or dead-lettered). * Setting the TTL to 0 causes messages to be expired upon reaching a queue * unless they can be delivered to a consumer immediately. */ expiration?: string; /** Application message identifier. */ messageId?: string; /** Message timestamp in seconds. */ timestamp?: number; /** Message type name. */ type?: string; /** Creating user id. */ userId?: string; /** Creating application id. */ appId?: string; clusterId?: string; } export type MessageBody = string | Buffer | any; type BasicPublishParams = MethodParams[Cmd.BasicPublish]; export interface Envelope extends HeaderFields, BasicPublishParams { } type BasicDeliverParams = MethodParams[Cmd.BasicDeliver]; /** May be received after creating a consumer with {@link Channel.basicConsume} */ export interface AsyncMessage extends HeaderFields, BasicDeliverParams { body: MessageBody; } type BasicGetOKParams = MethodParams[Cmd.BasicGetOK]; /** May be recieved in response to {@link Channel.basicGet} */ export interface SyncMessage extends HeaderFields, BasicGetOKParams { body: MessageBody; } type BasicReturnParams = MethodParams[Cmd.BasicReturn]; /** May be received after {@link Channel.basicPublish} mandatory=true or immediate=true */ export interface ReturnedMessage extends HeaderFields, BasicReturnParams { body: MessageBody; } export interface Decimal { scale: number; value: number; } export {};