Options that RabbitMQ connection was instantiated with.
Rabbit constructor.
This will be automatically called as part of the Io constructor if rabbit is enabled. The following options may be configured for Rabbit, as defined within the cog.json. The default values are shown below:
{
"url": "localhost",
"username": "guest",
"password": "guest",
"exchange": "amq.topic",
"vhost": "/",
}
If you wish to enable SSL for communication, you will need to set ssl
to true, and then point
the following keys at the appropriate file paths:
and optionally define a passphrase
for the key file.
Set the timeout in ms to use for the publishRpc method.
The default is 3000ms, which should be sufficient for most cases.
The new timeout in ms
Close the RabbitMQ connection. The connection is closed automatically when the Io instance is destroyed.
Publish a message to a RabbitMQ topic.
This method allows for passing content to the specified topic. The content can be a string, number, object, or buffer, and in the case of the first three, will be implicitly converted to a buffer before sending to RabbitMQ. In these cases, the content type will be automatically determined based on type and set as follows:
Buffer
- application/octet-stream
number
- text/number
string
- text/string
object
- application/json
If you wish to override the content type, you can pass options.contentType
to the method.
The routing key for the message.
The message to publish. If left blank, will default to an empty buffer.
Publishing options. See amqplib#publish for details on options.
Subscribe to a RabbitMQ topic.
For each method that is recieved for a topic, the callback will be called with the RabbitMQ message. On receiving the message,
the content
property will be automatically converted to an appropriate type based on the content type of the message. The content type
to be used can be overriden by setting the options.contentType
field. You should only need to set the content type if interfacing
with the legacy @cisl/io
package.
The expected type of the content is in the message. If not specified, defaults to string | numer | object | Buffer
.
The routing key for the message.
Subscribe to a RabbitMQ topic.
For each method that is recieved for a topic, the callback will be called with the RabbitMQ message. On receiving the message,
the content
property will be automatically converted to an appropriate type based on the content type of the message. The content type
to be used can be overriden by setting the options.contentType
field. You should only need to set the content type if interfacing
with the legacy @cisl/io
package.
The expected type of the content is in the message. If not specified, defaults to string | numer | object | Buffer
.
The routing key for the message.
The options to use. You can use this to specify a non-default exchange to listen to, as well as contentType to expect.
The promise returned by this method is resolved when the response is received from the callee. The response will be automatically parsed to the appropriate type based on the content type. You can override this behavior by setting options.contentType. You may leave both content and options blank.
The type of the content of the response. Defaults to string | number | object | Buffer
.
The name of the queue to use for the RPC.
The content to send to the callee. If left blank, will default to an empty buffer.
The options to use.
Listen for RabbitMQ remote procedure calls (RPC).
When a message is received on the given queue, the handler will be called with the message. The content of the message
is automatically parsed to the appropriate type based on the content type. You can override this behavior by setting the
options.contentType
setting.
The type of the content of the response. Defaults to string | number | object | Buffer
.
The name of the queue to use for the RPC.
The handler to use.
Listen for RabbitMQ remote procedure calls (RPC).
When a message is received on the given queue, the handler will be called with the message. The content of the message
is automatically parsed to the appropriate type based on the content type. You can override this behavior by setting the
options.contentType
setting.
The type of the content of the response. Defaults to string | number | object | Buffer
.
The name of the queue to use for the RPC.
The options to use.
The handler to use.
Listen to a RabbitMQ queue.
When a message is received on the given queue, the handler will be called with the message. The content of the message
is automatically parsed to the appropriate type based on the content type. You can override this behavior by setting the
options.contentType
setting.
The full allowed properties for options can be viwed at amqplib#assertQueue.
Queue name to listen to.
Handler to use.
Listen to a RabbitMQ queue.
When a message is received on the given queue, the handler will be called with the message. The content of the message
is automatically parsed to the appropriate type based on the content type. You can override this behavior by setting the
options.contentType
setting.
The full allowed properties for options can be viwed at amqplib#assertQueue.
Queue name to listen to.
Options to use.
Handler to use.
Get a list of queues declared in the rabbitmq server.
Subscribe to queue creation events
Callback to handle the event.
Subscribe to queue deletion events
Callback to handle the event.
Generated using TypeDoc
Class representing the Rabbit module