Subscribe to our list to receive the latest updates on Node on Fire

Class: MessageQueue

MessageQueue

new MessageQueue(connectionString)

The base message queue class and the MessageQueue module. This should be "subclassed" (prototypal inheritance...) by specific implementations. To create a message queue, use MessageQueue.factory.

Parameters:
Name Type Description
connectionString String

The connection string to the message queue.

Methods

<static> factory()

Factory constructor for the message queue system.

Creates an AMQP-based message queueing system if AMQP_URL is set.

Currently only AMQP is supported, but it should be very easy to add additional message queue systems.

To Do:
  • Move this to a separate module instead.
Returns:

A message queue instance, or null.

Type
MessageQueue

connect()

Gets invoked when the app is starting, both in the web process and the worker processes.

Returns:
Type
Promise

createTask(queueName, taskMap)

Publishes a task to a work queue.

Parameters:
Name Type Description
queueName String

The queue name to publish to.

taskMap Dictionary

Implementation specific information about the task.

disconnect()

Gets invoked when the app is shutting down, both the web or the worker process.

Returns:
Type
Promise

startConsumingTasks(queueName, callback)

Starts consuming tasks on a specific queue named queueName. The exact implementation is up to the subclass.

Parameters:
Name Type Description
queueName String

The name of the queue.

callback function

The callback to invoke whenever a message is received. The callback takes one parameter: a dictionary with the keys methodName and params. methodName is the name of the method to invoke on the worker and params the arguments passed to the method.

Do you have any questions or comments on this page? Start a discussion below.

comments powered by Disqus
Subscribe to our list to receive the latest updates on Node on Fire