Optional configuration options for the connection.
Optional
instrumentors: Partial<ConnectionInstrumentors>Optional instrumentors for various connection operations.
An instance of a connection to a RabbitMQ server.
Whether the connection is active or not.
1.0.9
If the connection is not active, it will not be possible to create new channels, meaning that it will not be possible to create new queues, publish messages, consume messages or acknowledge messages.
We use this flag to prevent operations that require an active connection from being executed
in both the Connection
and Queue
classes.
The amount of time to wait for the connection to become active or indicate closed / blocked before throwing an exception.
1.0.9
This value is used internally by the Connection
class to determine how long to wait for the connection to become active or indicate closed / blocked before throwing an exception
but can be set by the user by calling Connection.setActiveConnectionTimeout
if they want to change the default value.
Removes the specified event listener for the 'connected' event.
The name of the event to remove the listener from.
The function to be removed from the event listeners.
void
Removes the specified event listener for the 'error' event.
The name of the event to remove the listener from.
The function to be removed from the event listeners.
void
Removes the specified event listener for the 'close' event.
The name of the event to remove the listener from.
The function to be removed from the event listeners.
void
Removes the specified event listener for the 'blocked' event.
The name of the event to remove the listener from.
The function to be removed from the event listeners.
void
Removes the specified event listener for the 'unblocked' event. This event is emitted when the connection is unblocked after being blocked due to a flow control mechanism.
The name of the event to remove the listener from.
The function to be removed from the event listeners.
void
Removes the specified event listener for the 'before:close' event. This event is emitted before the connection is closed.
The name of the event to remove the listener from.
The function to be removed from the event listeners.
void
Registers an event listener for the 'connected' event. This event is emitted when the connection is established.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers an event listener for the specified event.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers an event listener for the 'close' event.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers an event listener for the 'blocked' event. This event is emitted when the connection is blocked due to a flow control mechanism.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers an event listener for the 'unblocked' event. This event is emitted when the connection is unblocked after being blocked due to a flow control mechanism.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers an event listener for the 'before:close' event. This event is emitted before the connection is closed.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers a one-time event listener for the 'connected' event. The listener is automatically removed after it has been called once.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers a one-time event listener for the 'error' event. The listener is automatically removed after it has been called once.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers a one-time event listener for the 'close' event. The listener is automatically removed after it has been called once.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers a one-time event listener for the 'blocked' event. The listener is automatically removed after it has been called once.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers a one-time event listener for the 'unblocked' event. The listener is automatically removed after it has been called once. This event is emitted when the connection is unblocked after being blocked due to a flow control mechanism.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Registers a one-time event listener for the 'before:close' event. This event is emitted before the connection is closed. The listener is automatically removed after it has been called once.
The name of the event to listen for.
The function to be called when the event is emitted.
void
Checks the status of all queues associated with the connection.
A Promise
that resolves to an object containing the name of each queue and its status.
An error if the connection is not established or if any of the queues cannot be checked.
1.0.4
Closes the connection to the RabbitMQ server.
A Promise
that resolves when the connection has been closed.
An error if the connection could not be closed.
The reason we don't check if the connection is active and just return if it is already inactive is because the connection may be "blocked" and we want to allow the user to close the connection even if it is blocked. Also, this function cleans up any channels which were opened by the connection, and shuts down any queues which were created by the connection.
Returns a Promise
that resolves to a Queue
instance with the specified name
.
If a Queue
instance with the specified name
was already created by the instance of the connection, it is returned instead, allowing you to re-use an existing connection channel.
The name of the queue to get or create.
Optional
options: Partial<ConnectionGetQueueOptions>Optional configuration options for the queue.
Optional
instrumentors: Partial<QueueInstrumentors>A Promise
that resolves to a Queue
instance.
An error if the queue could not be created / updated on the server.
Sets the amount of time to wait for the connection to become active or indicate closed / blocked before throwing an exception.
The amount of time to wait for the connection to become active or indicate closed / blocked before throwing an exception.
An error if the timeout is not an integer greater than or equal to 100 (100ms).
1.0.9
This value is used internally by the Connection
class to determine how long to wait for the connection to become active or indicate closed / blocked before throwing an exception
Returns a Promise
that resolves when the connection is active.
The maximum time to wait for the connection to become active.
A Promise
that resolves when the connection is active.
An error if the connection is not active within the specified timeout or is closed / blocked before becoming active.
1.0.9
Static
closeCloses all active connections.
A Promise
that resolves when all connections have been closed.
An error if any of the connections cannot be closed.
1.0.12
When the Connection class is imported, due to Live Bindings, this function will be able to close all connections that are created after the import. However, when the class is required as opposed to imported, this function will only be able to close connections that are created from within the file it is required in.
Classdesc
An instance of a connection to a RabbitMQ server