All Products
Search
Document Center

ApsaraMQ for RabbitMQ:Manage queues

更新時間:Jun 14, 2024

In ApsaraMQ for RabbitMQ, a queue is a message queue. Messages in ApsaraMQ for RabbitMQ are delivered to one or more queues. This topic describes how to create a queue to store messages, view the dashboard, view the statistics of a queue, bind an exchange to a queue, send messages to a queue, view consumer tags, clear a queue, and delete queues in the ApsaraMQ for RabbitMQ console.

Background information

A consumer tag is an identifier of a consumer client. You can specify a consumer tag on an ApsaraMQ for RabbitMQ consumer client. If you do not specify a consumer tag on an ApsaraMQ for RabbitMQ consumer client, the ApsaraMQ for RabbitMQ broker automatically generates a unique consumer tag for the client.

For information about how to specify a consumer tag, see Subscribe to messages.

Important
  • A consumer tag must be unique and can be used only by one consumer client at a time.

  • A consumer tag is valid only in one channel. The consumer tag that is created in a channel cannot be used in another channel.

Create a queue

  1. Log on to the ApsaraMQ for RabbitMQ console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar of the Instances page, select the region where the instance that you want to manage resides. Then, in the instance list, click the name of the instance that you want to manage.

  3. In the left-side navigation pane, click Queues.

  4. On the Queues page, click the drop-down arrow next to vhost. From the Change drop-down list, select the vhost on which you want to create a queue. Then, click Create Queue.

  5. In the Create Queue panel, enter a queue name in the Queue Name field and configure the Auto Delete parameter. Click Advanced Settings and configure the queue parameters that are displayed. Then, click OK.

    Table 1. Parameters

    Parameter

    Description

    Usage notes

    Queue Name

    The queue name.

    • The name can contain letters, digits, hyphens (-), underscores (_), periods (.), number signs (#), forward slashes (/), and at signs (@).

    • The name must be 1 to 255 characters in length.

    • After a queue is created, you cannot change its name. If you want to change the name of a queue, delete the queue and create another queue.

    • amq. is a reserved field and cannot be used as the prefix of an exchange name. For example, you cannot use amq.test as the name of an exchange.

    Auto Delete

    Specifies whether the queue is automatically deleted after the last subscription from consumers to the queue is canceled.

    • true: The queue is automatically deleted after the last subscription from consumers to this queue is canceled.

    • false: The queue is not automatically deleted after the last subscription from consumers to this queue is canceled.

    Advanced Settings

    Other parameters for the queue, such as the dead-letter exchange, dead-letter routing key, and message time-to-live (TTL).

    • DeadLetterExchange: the exchange to which dead-letter messages are delivered.

    • DeadLetterRoutingKey: the routing key of dead-letter messages. A dead-letter exchange sends dead-letter messages to the queue whose routing key matches the routing key of the dead-letter messages.

    • MessageTTL: the message TTL, in milliseconds. A message that is not consumed within the specified message TTL is a dead-letter message and is sent to a dead-letter exchange. For more information, see Message TTL.

View the statistics of a queue

You can view various metrics to identify and locate issues at the earliest opportunity.

  1. On the Queues page, find the queue that you want to manage and click Details in the Actions column.

  2. On the Queue Details page, click the Monitoring and Alerting or Dashboard tab.

    The statistics of a queue vary based on the instance edition. The following section describes the details of statistics of different instance editions.

    • Enterprise Edition and Enterprise Platinum Edition: You can view the metrics provided by Managed Service for Prometheus and Managed Service for Grafana. For information about the dashboard and metrics displayed on the dashboard, see Dashboard.

    • Standard Edition and Professional Edition: You can view the monitoring data provided by CloudMonitor. For information about metrics provided by CloudMonitor, see Monitoring and alerting.

      Note

      ApsaraMQ for RabbitMQ no longer allows you to purchase Standard Edition instances. You can continue using existing Standard Edition instances.

View consumer tags

Important

ApsaraMQ for RabbitMQ allows you to view only the consumer tags of connected consumer clients. Make sure that the consumer client whose consumer tags you want to view is connected to the broker.

On the Queues page, find the queue that you want to manage and choose More > Consumer Tags in the Actions column.

Bind an exchange to a queue

  1. On the Queues page, find the queue that you want to manage and click Details in the Actions column.

  2. On the Queue Details page, click the Bound as Destination tab. Then, click Add Binding.

  3. In the Add Binding panel, configure the Source Exchange and Routing Key parameters. Then, click Confirm.

    Note

    If the bound exchange is of the x-consistent-hash type, the routing key indicates the weight of the queue. The value of a weight must be an integer that ranges from 1 to 20.

Send messages to a queue

After you bind an exchange to a queue, you can send messages in the exchange to the specified queue in the ApsaraMQ for RabbitMQ console.

  1. On the Queues page, find the queue that you want to manage and click Details in the Actions column.

  2. On the Queue Details page, click the Bound as Destination tab.

  3. In the binding list, find the binding that you want to manage and click Send Message in the Actions column.

  4. In the Send Message panel, configure the Message ID and Message Body parameters. Then, click OK.

Clear a queue

On the Queues page, find the queue that you want to manage and choose More > Clear Messages in the Actions column.

Delete queues

Warning

After you delete a queue, messages that are not consumed in the queue are also deleted and cannot be restored. Exercise caution when you delete queues.

  1. On the Queues page, use one of the following methods to delete queues:

    • Delete a single queue: Find the queue that you want to delete and choose More > Delete in the Actions column.

      You can also click the name of the queue that you want to delete or click Details in the Actions column. Then, in the upper-right corner of the Queue Details page, click Delete.

    • Delete multiple queues: Select the queues that you want to delete and click Batch Delete below the queue list.

  2. In the Note message, click OK.