Create an AMQP action
Create an AMQP action when you want Events & Actions to forward matching PubNub events to a broker that speaks the Advanced Message Queuing Protocol (AMQP). RabbitMQ and CloudAMQP both work. You configure the action in the Admin Portal, and it connects to any correctly configured broker because Events & Actions is hosting-agnostic for AMQP.
If you already have a broker URL with TLS, credentials, and a vhost, skip to Configure the AMQP action.
Set up your AMQP broker
Gather the following information from your AMQP environment before you configure the action:
- An AMQP URL with TLS, credentials, and vhost.
- A routing key the exchange uses to route messages to the correct queue.
- Optionally, an exchange name for publishing messages.
If you use RabbitMQ, follow the RabbitMQ documentation to set up the broker, enable TLS, and create credentials and a vhost.
If you use CloudAMQP, follow the CloudAMQP documentation to do the same.
Configure the AMQP action
- In Events & Actions in the Admin Portal, select your app and keyset, then click + Add Action.
- Select Advanced Message Queuing Protocol (AMQP) as the action type.
- In URL, enter the connection string in the format
amqps://username:password@hostname/vhost, for exampleamqps://user123:pass456@bunny.cloudamqp.com/myvhost. - In Routing key, enter the routing key your exchange uses to route messages, for example
logs.warning. - If you want each message written to broker disk instead of kept only in memory, enable Persistent.
- If you want to publish through a specific exchange, enter its name in Exchange, for example
MyExchange. - If you need a queue TTL different from your broker's default, set TTL (min).
- If you want failed deliveries retried automatically, enable and configure AMQP retry. See Available actions for the retry policy and backoff formula.
- Click Add event listener and pair the action with an existing event listener, or create one.
- Click Save changes.
Publish a message that matches the paired listener's filter and confirm it arrives on your queue.
Related tasks
- Configure Events & Actions. Create the event listener that triggers this action.
- Available actions. Look up the retry and envelope settings shared by every action type.
- Create a Kafka action. Forward matching events to an Apache Kafka topic instead of an AMQP broker.
- Events & Actions. Understand event listeners, filters, and the concepts behind Events & Actions.