Optional
propsOrUrl: string | ConnectionOptionsTrue if the connection is established and unblocked. See also :BLOCKED | Connection#on('connection.blocked'))
Request a single message from a queue. Useful for testing.
Optional
noIf 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.
Optional
queue?: stringSpecifies the name of the queue to consume from.
Optional
queue: stringCreate a message consumer that can recover from dropped connections.
Process an incoming message.
Create a message publisher that can recover from dropped connections. This will create a dedicated Channel, declare queues, declare exchanges, and declare bindings. If the connection is reset, then all of this setup will rerun on a new Channel. This also supports retries.
This will create a single "client" Channel
on which you may publish
messages and listen for direct responses. This can allow, for example, two
micro-services to communicate with each other using RabbitMQ as the
middleman instead of directly via HTTP.
Optional
props: RPCPropsBind exchange to an exchange.
Optional
arguments?: Record<string, any>A set of arguments for the binding. The syntax and semantics of these arguments depends on the exchange class.
Specifies the name of the destination exchange to bind.
Optional
routingSpecifies 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.
Specifies the name of the source exchange to bind.
Verify exchange exists, create if needed.
Optional
arguments?: { Optional
alternate-Optional
autoIf set, the exchange is deleted when all queues have finished using it.
Optional
durable?: booleanIf 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 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?: booleanIf 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?: booleanIf 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?: stringdirect, 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.
Delete an exchange.
Name of the exchange
Optional
ifIf 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.
Unbind an exchange from an exchange.
Optional
arguments?: Record<string, any>Specifies the name of the destination exchange to unbind.
Optional
routingSpecifies the routing key of the binding to unbind.
Specifies the name of the source exchange to unbind.
The connection is successfully (re)established
The rabbitmq server is low on resources. Message publishers should pause. The outbound side of the TCP socket is blocked until "connection.unblocked" is received, meaning messages will be held in memory. https://www.rabbitmq.com/connection-blocked.html
The rabbitmq server is accepting new messages.
Returns a promise which is resolved when the connection is established. WARNING: if timeout=0 and you call close() before the client can connect, then this promise may never resolve!
Milliseconds to wait before giving up and rejecting the promise. Use 0 for no timeout.
By default this will automatically call
connection.close()
when the timeout is reached. If
disableAutoClose=true, then connection will instead continue to retry
after this promise is rejected. You can call close()
manually.
This method binds a queue to an exchange. Until a queue is bound it will not receive any messages. In a classic messaging model, store-and-forward queues are bound to a direct exchange and subscription queues are bound to a topic exchange.
Optional
arguments?: Record<string, any>Name of the exchange to bind to.
Optional
queue?: stringSpecifies the name of the queue to bind. If blank, then the last declared queue on the channel will be used.
Optional
routingSpecifies 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.
Declare queue, create if needed. If queue
empty or undefined then a
random queue name is generated (see the return value).
Optional
arguments?: { Optional
x-Optional
x-Optional
x-Queue Expiry https://www.rabbitmq.com/ttl.html#queue-ttl
Optional
x-Optional
x-Optional
x-Per-Queue Message TTL https://www.rabbitmq.com/ttl.html#per-queue-message-ttl
Optional
x-Optional
x-Optional
autoIf 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?: booleanIf 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?: booleanExclusive 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?: booleanIf 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?: stringThe 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.
Optional
queue: stringThis method deletes a queue. When a queue is deleted any pending messages
are sent to a dead-letter queue if this is defined in the server
configuration, and all consumers on the queue are cancelled. If queue
is
empty or undefined then the last declared queue on the channel is used.
Optional
ifIf set, the server will only delete the queue if it has no messages.
Optional
ifIf 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.
Optional
queue?: stringSpecifies the name of the queue to delete.
Optional
queue: stringRemove all messages from a queue which are not awaiting acknowledgment.
If queue
is empty or undefined then the last declared queue on the
channel is used.
Optional
queue: stringOptional
queue?: stringUnbind a queue from an exchange.
Optional
arguments?: Record<string, any>The name of the exchange to unbind from.
Optional
queue?: stringSpecifies the name of the queue to unbind.
Optional
routingSpecifies the routing key of the binding to unbind.
This represents a single connection to a RabbitMQ server (or cluster). Once created, it will immediately attempt to establish a connection. When the connection is lost, for whatever reason, it will reconnect. This implements the EventEmitter interface and may emit
error
events. Close it with Connection#close()Example