tencent cloud

Feedback

Policy Management

Last updated: 2024-09-29 10:49:15

    Overview

    In RabbitMQ message queue, besides forced attributes such as durable and Exclusive, when creating a Queue or an Exchange, you can configure some optional attributes to obtain different features, such as x-message-ttl, x-expires, and x-max-length.
    However, once the attribute parameters set for a Queue or an Exchange via RabbitMQ client are successfully set, they cannot be changed unless the original Queue or Exchange is deleted and a new one is created.
    A policy is a special use of runtime parameters that supports dynamically modifying some attribute parameters. Policies are aimed at the Vhost level, and a policy can match one or more Queues or Exchanges, facilitating batch management. This solves the problem that Exchanges and Queues created by RabbitMQ clients cannot be modified, and greatly enhances the flexibility of the application.

    Directions

    Creating a Policy

    When you create a cluster, if mirrored queue is enabled, there will be a default policy under the Policy tab in the console, which can be deleted,and you can also recreate or modify the policy.
    1. Log in to the RabbitMQ Console.
    2. In the left sidebar, choose Vhost, choose the region, then click the target Vhost's ID to enter the Basic Info page.
    3. Click Policy > Create Policy .
    
    
    
    4. Fill in the basic policy information. The console supports creating an Image policy or a Custom Policy, as described below:
    Mirroring Policy
    Custom Policy
    Basic Settings
    Current Vhost: Indicates which Vhost the image policy is being created for.
    Policy name: It can contain 1 to 64 characters consisting of only digits, letters, dots (.), hyphens (-), and underscores (_).
    Matching pattern: A regular expression used to match relevant Queues. Commonly used regular expressions for matching patterns are listed in the table below:
    Regular Expression
    Description
    .*
    Matches all Queues under the current Vhost.
    ^test.*
    Matches all Queues under the current Vhost whose names start with test.
    .*test.*
    Matches all Queues under the current Vhost whose names contain test.
    .*test$
    Matches all Queues under the current Vhost whose names end with test.
    Policy type: Select Image Policy.
    Scope of application: Specifies the range in which the current policy is effective. The image policy is only applicable within Queues.
    Priority: Defines the priority of the policy. If multiple policies apply to the same Queue, only the policy with the highest priority number will take effect.
    Policy Definition
    Image mode: Defines the mode for the image Queue, with valid values being all, exactly, and nodes.
    all: Creates an image of the Queue on all nodes in the cluster.
    exactly: Creates an image on a specified number of nodes, with the number of nodes defined by the Image Parameters++++.
    nodes: Creates an image on specified nodes, with node names defined through the image parameters.
    Image parameters: Specifies the nodes to which messages will be synchronized.
    When image mode is set to all, this field does not need to be filled.
    When image mode is set to exactly, the image parameters can specify at least 1 node, up to the total number of nodes in the current cluster.
    When image mode is set to nodes, the image parameters allow you to select specific nodes by their names.
    Message synchronization method: Defines how messages are synchronized in the image Queue, with options of automatic or manual.
    Primary node exit handling: Specifies whether to allow the election of an unsynchronized image as the master when the primary node gracefully exits.
    Primary node failure handling: Specifies whether to allow the election of an unsynchronized image as the master when the primary node fails or experiences a fault. To ensure availability, it is recommended to keep this setting as Allow selection of all replicas.
    
    
    
    Custom Policy
    Basic Settings
    Current Vhost: Indicates which Vhost the image policy is being created for.
    Policy name: It can contain 1 to 64 characters consisting of only digits, letters, dots (.), hyphens (-), and underscores (_).
    Matching pattern: A regular expression used to match relevant Queues or Exchanges. Commonly used regular expressions for matching patterns are listed in the table below:
    Regular Expression
    Description
    .*
    Matches all Queues or Exchanges under the current Vhost.
    ^test.*
    Matches all Queues or Exchanges under the current Vhost whose names start with test.
    .*test.*
    Matches all Queues or Exchanges under the current Vhost whose names contain test.
    .*test$
    Matches all Queues or Exchanges under the current Vhost whose names end with test.
    Policy type: Select Image Policy.
    Scope of application: Specifies the range in which the current policy is effective.
    Exchanges and Queues: Indicates that the policy applies to all Queues or Exchanges that match the specified pattern.
    Queues: Indicates that the policy applies to all Queues that match the specified pattern.
    Exchanges: Indicates that the policy applies to all Exchanges that match the specified pattern.
    Priority: Defines the priority of the policy. If multiple policies apply to the same Queue or Exchange, the policy with the highest priority number will take effect.
    
    
    
    Policy Definition
    You can select the necessary fields for the policy definition, as shown in the following diagram.​
    
    
    
    Currently, the cloud console supports the fields listed in the table below. For additional fields, use the open-source console to create them.
    Field Category
    Field Name
    Description
    Data Type Restriction
    Queues (All Types)
    Max Length
    Maximum number of messages allowed in the queue. Once the number of messages reaches this limit, based on the Overflow Behavior setting, old messages will be deleted, or new messages will be rejected.
    Number
    Queues (All Types)
    Max Length Bytes
    Maximum total message byte size allowed in the queue. Once the total byte size of messages reaches this limit, based on the Overflow Behavior setting, old messages will be deleted, or new messages will be rejected.
    Number
    Queues (All Types)
    Overflow Behaviour
    The behavior when the queue reaches its maximum length or byte limit. Valid values are:
    drop-head: Deletes the old messages from the head of the queue.
    reject-publish: Rejects newly published messages.
    String
    Queues (All Types)
    Auto Expire
    The auto-expiration time of the queue, measured in milliseconds. If the queue is not accessed within this time (e.g., no messages are published, consumed, or the queue’s status is not checked), the queue will be deleted.
    Number
    Queues (All Types)
    Dead letter exchange
    Dead letter exchange. When messages are deleted due to exceeding their TTL, reaching the maximum queue length, or being rejected by consumers, they will be sent to the specified dead letter exchange.
    String
    Queues (All Types)
    Dead letter routing key
    Dead letter routing key. This routing key can be used to route messages when they are sent to the dead letter exchange.
    String
    Queues [Classic]
    Message TTL
    Time to Live (TTL) for messages. Measured in milliseconds, this value defines the maximum amount of time a message can remain in the queue. Once the message exceeds this time, it will be deleted. If the message is consumed (and acknowledged) by a consumer or republished to another queue, the timer will be reset.
    Number
    Queues [Classic]
    Lazy mode
    Lazy mode. When this mode is enabled, RabbitMQ will store as many messages as possible on disk to reduce memory usage.
    String ("lazy")
    Queues [Quorum]
    Max in memory length
    The maximum number of unacknowledged messages that each consumer is allowed to consume before acknowledging them.
    Number
    Queues [Quorum]
    Max in memory bytes
    Maximum total memory bytes allowed for the queue. When the memory usage of messages exceeds this limit, RabbitMQ will attempt to write the excess to disk to reduce memory usage. Note that this setting may not apply to queues with Lazy Mode enabled, as RabbitMQ will store messages on disk by default in Lazy Mode.
    Number
    Queues [Quorum]
    Delivery limit
    The maximum number of unacknowledged messages each consumer is allowed to consume before acknowledging them.
    Number
    Exchanges
    Alternate exchange
    Alternate exchange. When messages cannot be routed to any queue (e.g., no matching routing key or queue), they will be sent to the specified alternate exchange.
    String
    5. Click Done to complete the policy creation. You will be able to see the created policy in the policy list..

    Editing a Policy

    In the policy list, click Edit in the Operation column of the target policy.
    1. In the pop-up window, edit the policy information.
    2. Click Complete to complete the modification.

    Deleting a Policy

    1. In the policy list, find the policy you want to delete, and click Delete in the Operation column.
    2. In the pop-up prompt box, click Delete to complete the deletion.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support