RabbitMQ Consumer
The SimpleOne system can be configured as a consumer application that can accept messages from third-party services through a connection to the RabbitMQ message broker.
RabbitMQ acts as an intermediary to route messages from the external application to specific queues where the messages are stored until they are delivered to the consumer.
To connect to a specific RabbitMQ queue, create a consumer entry in the system. To do so, complete the following steps:
- Navigate to External Queues → RabbitMQ Consumers.
- Click New and fill in the required fields.
- Click Save or Save and exit to apply the changes.
RabbitMQ Consumer form fields
Field | Mandatory | Description |
---|---|---|
Name | Y | Specify a consumer name. |
Active | N | Select the checkbox to activate the consumer record. |
Enable debug | N | Select the checkbox to enable advanced logs. Use them to identify problems when configuring consumer settings. |
Host name | Y | Enter a RabbitMQ host name to connect to in the example.com format. |
Port | Y | Specify the server connection port. |
Virtual host | N | Specify the host designated in the RabbitMQ server settings. |
Queue name | Y | Specify the name of the queue that you need to receive the messages from. |
Username | Y | Specify a user login for the RabbitMQ server connection. Do not use special symbols in usernames to avoid connection failures. |
Password | Y | Specify a user password for the RabbitMQ server connection. Do not use special symbols in password to avoid connection failures. |
Connection time out | N | Set the RabbitMQ server connection time out. |
Run as user | Y | Select the user on whose behalf to execute the script. |
Script | Y | Enter a script that will process received messages and invoke certain actions in the system. The following variables are available in the script:
|
(function(body, headers) {
ss.info(body + JSON.stringify(headers));
})(body, headers)
Consumers do not create queues, they only connect to existing ones. After establishing a connection to the RabbitMQ server, the target queue may be empty. Messages are only delivered when there are new messages in the queue.
Unloading and processing messages do not happen at the same time. The message is read from the outer queue and enters the inner queue, where it waits for its turn to be processed.
If the connection to the server is lost, the consumer automatically attempts to restore the connection. The time between the attempts is determined by the Connection time out field and is 30 seconds by default.