AMQP Notifications
Account Setup
Section titled “Account Setup”AMQP lets Apprise publish notifications through a message broker such as RabbitMQ, Apache ActiveMQ Artemis, Apache Qpid, or Azure Service Bus. Consumers connected to the destination receive each message.
Two very different protocols share the AMQP name. Install the library for the one your broker speaks (or both):
| Version | Used by | Install |
|---|---|---|
| 0.9.1 | RabbitMQ (its default) and most brokers that call themselves “AMQP” | pip install pika |
| 1.0 | ActiveMQ Artemis, Qpid, Azure Service Bus, RabbitMQ 4.0 and later | pip install python-qpid-proton |
When you do not set ?version=, Apprise uses 0.9.1 if pika is installed and 1.0 otherwise.
AMQP 0.9.1
Section titled “AMQP 0.9.1”Each target is a routing key. With the default exchange, use the name of an existing queue.
To publish to another exchange, add ?exchange=. For example, ?exchange=amq.topic with a target of alerts.disk reaches every queue bound to that topic. A fanout exchange broadcasts the message and needs no target.
Each message must reach at least one queue, otherwise the notification is reported as failed. Add ?mandatory=no if you only want the broker to accept it.
AMQP 1.0
Section titled “AMQP 1.0”Each target is an address (a queue or topic name). Exchanges do not exist in AMQP 1.0, so ?exchange= and ?mandatory= are ignored (with a warning) when ?version=1.0 is set.
RabbitMQ 4.0 and later expect addresses such as /queues/alerts or /exchanges/amq.topic/alerts.disk. Slashes split a normal URL path, so place these addresses in ?to= and separate multiple addresses with commas: ?to=/queues/alerts,/queues/backup.
To pick a RabbitMQ virtual host over AMQP 1.0, use ?vhost=vhost:name.
Syntax
Section titled “Syntax”Valid syntax is as follows:
amqp://{host}/{target}amqp://{host}:{port}/{target}amqp://{user}:{password}@{host}/{target}amqp://{user}:{password}@{host}:{port}/{target1}/{target2}/{targetN}amqp://{user}:{password}@{host}/?exchange={exchange}amqp://{user}:{password}@{host}/?version=1.0&to={address1},{address2}
For a secure (TLS) connection, use amqps:// instead:
amqps://{user}:{password}@{host}/{target}amqps://{user}:{password}@{host}:{port}/{target1}/{target2}/{targetN}
Parameter Breakdown
Section titled “Parameter Breakdown”| Variable | Required | Description |
|---|---|---|
| hostname | Yes | The broker you are sending your notification to. |
| port | No | The port the broker is listening on. The default is 5672 for amqp:// and 5671 for amqps://. |
| user | No | The user to log in with. Without one, AMQP 0.9.1 uses the broker’s guest account and AMQP 1.0 logs in anonymously. |
| password | No | The password for your user. |
| target | No | One or more routing keys (AMQP 0.9.1) or addresses (AMQP 1.0) to publish to. A target is optional only when AMQP 0.9.1 publishes to an exchange. |
| to | No | An alias of target. Use it for targets that contain a slash. |
| version | No | The AMQP version to use: 0.9.1 or 1.0. Shorter forms such as 0.9 and 1 also work. ver is an alias. The default is 0.9.1 when pika is installed, otherwise 1.0. Using exchange or mandatory without a version selects 0.9.1. |
| exchange | No | AMQP 0.9.1 only. The exchange to publish to. The default is the broker’s default exchange, which delivers straight to the queue named by each target. |
| vhost | No | The virtual host to use. The default is / for AMQP 0.9.1. For RabbitMQ over AMQP 1.0, use vhost:name. |
| persistent | No | Ask the broker to save messages to disk so they survive a restart. The default is yes. |
| mandatory | No | AMQP 0.9.1 only. Report a failure when a message does not reach any queue. The default is yes. |
| priority | No | The message priority, from 0 to 255. Your queue must be set up for priorities for this to have an effect. Not set by default. |
| ttl | No | How long (in milliseconds) the message may wait in a queue before it expires. Not set by default, so it never expires. |
| +header | No | Adds a message header. For example ?+source=nas attaches the header source with the value nas. Use as many as you like. |
Global Parameters
Section titled “Global Parameters”| Variable | Description |
|---|---|
| overflow | Controls messages that exceed a service’s documented limit. The default is upstream.👉 upstream: Send one message without splitting or truncating it for that limit.👉 truncate: Keep the portion that fits and discard the rest.👉 split: Prefer a readable break, fall back to a hard boundary, and send every part in order.Splitting undeclared or structured content is best effort. Use upstream when the body must remain one intact document. |
| format | This parameter can be set to either text, html, or markdown. Some services support the ability to post content by several different means. The default of this varies (it can be one of the 3 mentioned at any time depending on which service you choose). You can optionally force this setting to stray from the defaults if you wish. If the service doesn’t support different types of transmission formats, then this field is ignored. |
| verify | External requests made to secure locations (such as through the use of https) will have certificates associated with them. By default, Apprise will verify that these certificates are valid; if they are not then no notification will be sent to the source. In some occasions, a user might not have a certificate authority to verify the key against or they trust the source; in this case you will want to set this flag to no. By default it is set to yes. |
| redirect | By default, Apprise will follow HTTP redirects (3xx responses) issued by the remote server, matching the behaviour of the underlying requests library. If you want to prevent custom headers and credentials from being forwarded to destinations that differ from the original URL, set this to no. By default it is set to yes. |
| cto | This stands for Socket Connect Timeout. This is the number of seconds Requests will wait for your client to establish a connection to a remote machine (corresponding to the connect()) call on the socket. The default value is 4.0 seconds. |
| rto | This stands for Socket Read Timeout. This is the number of seconds the client will wait for the server to send a response. The default value is 4.0 seconds. |
| emojis | Enable Emoji support (such as providing :+1: would translate to 👍). By default this is set to no. Note: Depending on server side settings, the administrator has the power to disable emoji support at a global level; but default this is not the case. |
| tz | Identify the IANA Time Zone Database you wish to operate as. By default this is detected based on the configuration the server hosting Apprise is running on. You can set this to things like America/Toronto, or any other properly formated Timezone describing your area. |
| retry | The number of additional delivery attempts to make after the first failure before giving up. Accepts an integer in the range 0 to 10. The default is 0 (no retries – a single attempt is made). When combined with wait, Apprise pauses the specified number of seconds between each attempt. |
| wait | The number of seconds to pause between retry attempts. Accepts a decimal value in the range 0.0 to 20.0; integer values are promoted to float automatically. The default is 0.5. This value is only meaningful when retry is greater than zero – a service with retry=0 makes exactly one attempt regardless of the wait value. |
| optional | When set to yes, a delivery failure for this service is silently absorbed. The overall notify() call still evaluates as true even if this endpoint was unreachable, provided that every required (non-optional) service in the same batch succeeded. Setting this flag does not skip delivery or bypass retry logic – all configured retry attempts are still made before the failure is absorbed. By default this is set to no, meaning every failure is propagated to the caller. |
Examples
Section titled “Examples”Publish to the queue alerts on a local RabbitMQ:
apprise -vv -t "Disk Space" -b "The backup disk is 90% full" \ "amqp://guest:guest@localhost/alerts"Publish a high-priority message to two queues over TLS and expire it after one minute:
apprise -vv -b "The backup disk is 90% full" \ "amqps://user:pass@rabbit.example.com/alerts/backup?priority=9&ttl=60000"Publish to a topic exchange with a routing key and a custom header:
apprise -vv -b "The backup disk is 90% full" \ "amqp://user:pass@localhost/alerts.disk?exchange=amq.topic&+source=nas"Publish over AMQP 1.0 to a RabbitMQ queue:
apprise -vv -b "The backup disk is 90% full" \ "amqp://user:pass@localhost/?version=1.0&to=/queues/alerts"Publish over AMQP 1.0 to a queue on ActiveMQ Artemis or Qpid:
apprise -vv -b "The backup disk is 90% full" \ "amqp://user:pass@localhost/alerts?version=1.0"Testing
Section titled “Testing”RabbitMQ 4.0 and later support both AMQP 0.9.1 and AMQP 1.0, making it easy to try both versions locally with Docker:
# Start RabbitMQ; the web console is at http://localhost:15672 (guest/guest)docker run --rm --name rabbitmq -p 5672:5672 -p 15672:15672 \ rabbitmq:4-management
# Create a queue named "alerts" in the web console, then:apprise -vvv -b "Hello over 0.9.1" "amqp://guest:guest@localhost/alerts"apprise -vvv -b "Hello over 1.0" \ "amqp://guest:guest@localhost/?version=1.0&to=/queues/alerts"Questions or Feedback?
Technical Issues
Having trouble with the code? Open an issue on GitHub: