RabbitMQ
Publish Dataflow's events to a RabbitMQ exchange over TLS, with a user that may only write to it.
Each event is published to your exchange, with the topic (run.completed…) as routing key. Your bindings decide which queues get it.
Set up RabbitMQ
Open a TLS listener to the internet
Dataflow connects over AMQP with TLS (amqps), on port 5671 (or 9092, 9093, 9094, 9096). The broker's certificate must be valid for its host name and issued by a public certificate authority: self-signed certificates are refused. The host name must resolve to a public address.
Create the exchange and bind a queue
A topic exchange lets you bind on patterns of event types:
rabbitmqadmin declare exchange name=dataflow-events type=topic durable=true
rabbitmqadmin declare queue name=dataflow-runs durable=true arguments='{"x-queue-type": "quorum"}'
rabbitmqadmin declare binding source=dataflow-events destination=dataflow-runs routing_key='run.*'# as routing key binds every topic. A message that matches no binding is dropped by RabbitMQ, and the delivery still shows OK.
Create a user that may only write to the exchange
rabbitmqctl add_user dataflow 'A_LONG_RANDOM_PASSWORD'
rabbitmqctl set_permissions -p / dataflow '^$' '^dataflow-events$' '^$'The three patterns are configure, write and read: nothing to declare, write to dataflow-events only, nothing to read. To publish to the default exchange instead, the write pattern is '^amq\.default$'. Use a user name and password without / ? # % @ : or spaces.
Add the destination
curl https://dataflow.piloterr.com/v1/destinations \
-H "x-api-key: YOUR_API_KEY" -H "content-type: application/json" \
-d '{
"type": "rabbitmq",
"config": { "host": "rabbit.example.com", "port": 5671, "vhost": "prod", "exchange": "dataflow-events", "tls": true },
"credentials": { "username": "dataflow", "password": "A_LONG_RANDOM_PASSWORD" },
"topics": ["run.completed", "run.failed"]
}'| Field | Required | Secret | Holds |
|---|---|---|---|
config.host | yes | no | The broker's host name, without scheme or port. |
config.port | no | no | 5671 by default; 5671, 9092, 9093, 9094 or 9096. |
config.vhost | no | no | The virtual host. Left out: the server's default (/). |
config.exchange | no | no | Where events are published. Left out: the default exchange, which routes each event to a queue named like its topic (run.completed). |
config.tls | no | no | true by default, and required. |
credentials.username | yes | yes | The RabbitMQ user. |
credentials.password | yes | yes | Its password. |
Credentials are stored encrypted and shown masked. To change them, send both again with PATCH. See Credentials.
Network
Dataflow connects from our egress address, 116.203.84.164 (exit_ips of GET /v1/destinations/types): allow it on the broker's port in your firewall. Private addresses, names that resolve to one, plain AMQP and other ports are refused when you save (422 validation_failed).
What the exchange receives
- Routing key: the topic, such as
run.completed. - Body: the event payload, with content type
application/json. - Headers:
event-id(the payload'sid: deduplicate on it),topicandtimestamp(when it was sent, RFC 3339).
Messages are published without the persistent flag. Bind a quorum queue, as above, or a durable classic queue with your own policy, if they must survive a broker restart.
Test it
Send a test event from the dashboard, or POST /v1/destinations/{id}/test (details), then look at the queue in the management interface (Queues → Get messages).
code or error | Fix |
|---|---|
422 validation_failed on config.host | Use a public host name; private and .internal addresses are refused. |
422 validation_failed on config.tls | Turn TLS on: plain AMQP is refused. |
dns_error, connection_refused, timeout | Check the host and port, and that your firewall allows our address. |
tls_error | Use a certificate from a public authority, valid for the host name. |
auth_failed | Check the user name and password, and that the user may use the virtual host. |
access_denied | The user's write permission does not match the exchange. |
exchange_not_found | Create the exchange, in this virtual host, with this exact name. |
OK but the queue is empty | No binding matches the topic: bind with # or run.*. |
Other errors: Errors.