Connect RabbitMQ
The RabbitMQ connector holds a broker's address and user, so a RabbitMQ queue source can take file announcements from a queue, process each file in a Knowledge, and publish the result to another queue.
Who can set it up
- In Rational AI: a role with Create on the Connectors row to add the connector, Create on the Sources row and Use on the Connectors row to add the source, and Update on the Knowledge row to attach it. Sources needs the Knowledge module in your license. See Manage roles and users.
- On the broker: the broker's administrator, who creates the user and the queues.
What you need
- The broker's host, port, and virtual host, and whether it requires TLS.
- The queue that announces files, for example
pod-uploaded, and the queue for results, for examplepod-processed. Rational AI doesn't create queues, so both must exist. - Messages that are JSON objects with a field holding each file's
http://orhttps://URL. - If the file URLs need authentication, a token Rational AI can send as a Bearer token.
- A Knowledge to receive the files.
Give the Rational AI user only these permissions on its virtual host:
| Permission | Why it's needed |
|---|---|
| Read on the announcement queue | Takes messages from the queue. |
Write on the exchange that results go to, amq.default for the default exchange | Publishes each result. Not needed if you leave Result queue empty. |
| No Configure permission | Rational AI never declares or deletes queues or exchanges. |
Set up
-
On the broker, create a user for Rational AI and set its permissions on the virtual host. For example, with
rabbitmqctl:rabbitmqctl set_permissions -p / rational "" "^amq\.default$" "^pod-uploaded$". -
In Rational AI, go to Settings → Connectors, select Add, select RabbitMQ, then select Add.
-
Enter a Name and the Host, for example
rabbitmq.example.com. Enter the Port only if it isn't5672, or5671with TLS, and turn on Use TLS if the broker requires it. -
Enter the Virtual host (default
/), the Username, and the Password. -
Optionally, enter a File download token. Rational AI sends it as a Bearer token when it downloads the files the messages point to.
-
Select Add.
-
Go to Settings → Sources and select Add. Enter a Name. In Type, find RabbitMQ queue and select your connector under it.
-
Fill in the queue settings:
Field What to enter Queue The queue to consume. Required. Result queue Where results are published. Leave it empty to publish nothing. Result exchange (optional) Leave it empty for the default exchange. Otherwise results go to this exchange with the result queue as the routing key. File URL field The message field that holds the file's URL, for example url(the default) orpod.downloadUrl.Message ID field (optional) The field that identifies the message, for example requestId. Empty uses the message ID set on the broker.Files in flight How many files may wait for a result at once, from 1 to 256. Default 16.Delete each file once its result is published Removes the file from the Knowledge after its result is sent. Needs a Result queue. -
Select Add.
-
Go to Settings → Knowledge, open the Knowledge, select the Sources tab, and pick the source in Add source....
-
In Settings → Sources, open the source and select Sync now to start consuming the queue.
What gets synced
Each message announces one file. Rational AI downloads it into the Knowledge with the message saved next to it, processes it, and publishes a result. The result message contains:
messageId, and the original message asrequeststatus,processedorerror, and theerrortext when there is onefile, with the file's ID, name, and Knowledge IDattributes, the attributes extracted from the filereceivedAt,processedAt, andpublishedAttimestamps
A started source keeps consuming the queue, also after a restart of the platform, until you select Stop sync. It has no sync schedule and no Automatic or Periodic mode. Rational AI takes new messages only while fewer than Files in flight files wait for a result, so a backlog stays in the queue.
Limits
- The source writes every file to the first Knowledge it was attached to. Until it's attached, messages wait in the queue.
- Delivery is at least once in both directions. Your system may receive the same result twice, so match results by
messageIdand ignore duplicates. - A message that isn't a JSON object or has no valid URL is answered with an
errorresult. So is a file whose server refuses the download, or still fails after three attempts on a server error or a network error. - The Port and Use TLS are set when you add the connector. To change them, add a new connector. You can edit the host, virtual host, username, password, and token.
Troubleshooting
| Symptom | What to check |
|---|---|
| "The host must be a host name or an IP address, for example rabbitmq.example.com" | Remove the scheme, port, or path from Host. The port has its own field. |
| "Enter the queue to consume." | Queue is empty. Enter the name of an existing queue. |
| "Files can only be deleted after publishing when there is a result queue to publish to." | Enter a Result queue, or clear Delete each file once its result is published. |
| The source shows a failed status | The queue can't be consumed. Select the status to read the reason: wrong credentials, a missing queue, missing Read permission, or a TLS mismatch. Rational AI retries with a growing delay. |
| Messages stay in the queue | The source isn't attached to a Knowledge, or it was never started. Attach it, then select Sync now. |
| Results come back with "The message has no 'url' field with the file URL." | The File URL field doesn't match your messages. Enter the field's dotted path, for example pod.downloadUrl. |
Next steps
- Create a processing rule: choose which workflow extracts the attributes returned in each result.
- Configure data sources: source settings common to every type.
- Connect HTTP addresses: sync files from fixed web addresses instead.