Class: RabbitMQ

RabbitMQ

RabbitMQ model. Can be used independently for publishing or other uses.

Constructor

new RabbitMQ(optsopt)

Parameters:
Name Type Attributes Description
opts Object <optional>
RabbitMQ connection options.
Properties
Name Type Attributes Default Description
channel Object <optional>
RabbitMQ channel options.
Properties
Name Type Attributes Description
prefetch Object <optional>
Set prefetch for each consumer in a channel.
hostname String <optional>
localhost Hostname for RabbitMQ. Can be set with environment variable RABBITMQ_HOSTNAME.
port Number <optional>
5672 Port for RabbitMQ. Can be set with environment variable RABBITMQ_PORT.
username String <optional>
Username for RabbitMQ. Can be set with environment variable RABBITMQ_USERNAME.
password String <optional>
Username for Password. Can be set with environment variable RABBITMQ_PASSWORD.
Author:
  • Bryan Kendall
Source:

Methods

connect() → {Promise}

Connect to the RabbitMQ server.
Source:
Returns:
Promise that resolves once connection is established.
Type
Promise

disconnect() → {Promise}

Disconnect from RabbitMQ.
Source:
Returns:
Promise resolved when disconnected from RabbitMQ.
Type
Promise

publishEvent(queue, content) → {Promise}

Sends an object representing a message to an exchange for the specified event.
Parameters:
Name Type Description
queue String Exchange to receive the message.
content Object Content to send.
Source:
Returns:
Promise resolved when message is sent to the exchange.
Type
Promise

publishTask(queue, content) → {Promise}

Takes an object representing a message and sends it to a task queue.
Parameters:
Name Type Description
queue String Task queue to receive the message.
content Object Job to send.
Source:
Returns:
Promise resolved when message is sent to queue.
Type
Promise

publishToExchange(queue, routingKey, content) → {Promise}

Takes an object representing a message and sends it to an exchange using a provided routing key. Note: Providing an empty string as the routing key is functionally the same as sending the message directly to a named queue. The function RabbitMQ#publishToQueue is preferred in this case.
Parameters:
Name Type Description
queue String Exchange to receive the message.
routingKey String Routing Key for the exchange.
content Object Content to send.
Deprecated:
  • Yes
Source:
Returns:
Promise resolved when message is sent to the exchange.
Type
Promise

publishToQueue(queue, content) → {Promise}

Takes an object representing a message and sends it to a queue.
Parameters:
Name Type Description
queue String Queue to receive the message.
content Object Content to send.
Deprecated:
  • Yes
Source:
Returns:
Promise resolved when message is sent to queue.
Type
Promise