Skip to content

Reference: Policy CRD

A Policy applies settings to every queue or exchange in a virtual host whose name matches a regular expression. Use policies for settings such as message TTL, length limits, dead-lettering and delivery limits. Unlike queue arguments, you can change a policy at any time, and RabbitMQ applies the change to the matching queues and exchanges. When more than one policy matches the same queue or exchange, only the policy with the highest priority applies.

  • apiVersion: rabbitmq.com/v1beta1
  • kind: Policy
  • Scope: Namespaced

This page documents the RabbitMQ Messaging Topology Operator v1.20.6.

Example

apiVersion: rabbitmq.com/v1beta1
kind: Policy
metadata:
  name: my-app-tasks-policy
  namespace: your-application-namespace
spec:
  # The name of the policy inside RabbitMQ
  name: tasks-limits
  vhost: my-app-vhost
  pattern: "^tasks\\."
  applyTo: quorum_queues
  priority: 1
  definition:
    max-length: 100000
    overflow: reject-publish
    delivery-limit: 20
    dead-letter-exchange: tasks.dlx
  rabbitmqClusterReference:
    name: my-rabbitmq-cluster

Specification (spec)

Field Type Description
name string Required. The name of the policy in RabbitMQ. You cannot change this field after creation.
vhost string Optional. The RabbitMQ name of the virtual host. Default: /. You cannot change this field after creation.
pattern string Required. A regular expression that RabbitMQ matches against queue and exchange names, for example "^amq.".
applyTo string Optional. The kind of object the policy applies to. Allowed values: queues, classic_queues, quorum_queues, streams, exchanges, all. Default: all.
priority integer Optional. The priority of the policy. When more than one policy matches a queue or exchange, the policy with the greatest priority applies. Default: 0.
definition object Required. The policy keys and values as key-value pairs, for example max-length: 100000 or message-ttl: 60000. See RabbitMQ policies for the supported keys.
rabbitmqClusterReference object Required. The RabbitMQ cluster to create the policy in. You cannot change this field after creation. See spec.rabbitmqClusterReference.

spec.rabbitmqClusterReference

Identifies the RabbitMQ cluster. Set either name or connectionSecret, but not both.

Field Type Description
name string Optional. The name of the RabbitmqCluster resource. Set this field or connectionSecret.
namespace string Optional. The namespace of the RabbitmqCluster. Defaults to the namespace of the Policy. A cluster in another namespace accepts the reference only if its rabbitmq.com/topology-allowed-namespaces annotation lists your namespace.
connectionSecret object Optional. A reference (name) to a Secret with the keys uri, username and password for the management API of a RabbitMQ cluster that the RabbitMQ Cluster Operator does not manage. The Secret must have the label rabbitmq.com/topology-operator: "true". Set this field or name.

Status (status)

Field Type Description
conditions []object The Ready condition is True with reason SuccessfulCreateOrUpdate when the policy exists in RabbitMQ, and False with reason FailedCreateOrUpdate and an error message otherwise. RabbitMQ rejects unknown or invalid definition keys, and the error appears here.
observedGeneration integer The most recent metadata.generation that the operator reconciled.

Platform Notes

  • We provision and manage the RabbitmqCluster resource in your namespace and give you its name. Set spec.rabbitmqClusterReference.name to that name. See Getting Started.

Further Reading