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​

  1. In Events & Actions in the Admin Portal, select your app and keyset, then click + Add Action.
  2. Select Advanced Message Queuing Protocol (AMQP) as the action type.
  3. In URL, enter the connection string in the format amqps://username:password@hostname/vhost, for example amqps://user123:pass456@bunny.cloudamqp.com/myvhost.
  4. In Routing key, enter the routing key your exchange uses to route messages, for example logs.warning.
  5. If you want each message written to broker disk instead of kept only in memory, enable Persistent.
  6. If you want to publish through a specific exchange, enter its name in Exchange, for example MyExchange.
  7. If you need a queue TTL different from your broker's default, set TTL (min).
  8. If you want failed deliveries retried automatically, enable and configure AMQP retry. See Available actions for the retry policy and backoff formula.
  9. Click Add event listener and pair the action with an existing event listener, or create one.
  10. Click Save changes.

Publish a message that matches the paired listener's filter and confirm it arrives on your queue.

Was this page useful?

Last updated on