After you access Message Queue for RabbitMQ from an application, you must create resources, such as instances, a pair of username and password, vhosts, exchanges, queues, bindings, and an AccessKey pair.

Create an instance

Notice
  • Message Queue for RabbitMQ no longer allows you to create pay-as-you-go instances. You can create only subscription instances. Existing pay-as-you-go instances can continue to be used.
  • You are not allowed to manually release a subscription instance. When a subscription instance expires, the instance is automatically released. You can delete the records of expired subscription instances from the console.
  1. Log on to the Message Queue for RabbitMQ console.
  2. In the left-side navigation pane, click Instances.
  3. On the Instances page, click Create Instance.
  4. Purchase an instance by using one of the following methods:
      1. In the Purchase panel, select a subscription duration, set other parameters as required, and then click Buy Now.
      2. In the Unpaid Orders panel, confirm the order information and click Purchase.
      1. Click Go to Buy Page. On the Message Queue for RabbitMQ Subscription page, select a subscription duration, set other parameters as required, and then click Buy Now.
      2. On the Confirm Order page, read and select I have read and agree to Message Queue for RabbitMQ (Subscription) Agreement of Service and click Pay.
      3. On the Purchase page, click Purchase.

Create a pair of username and password

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance is located.
  3. On the Instances page, click the name of your instance.
  4. In the left-side navigation pane, click Static Accounts.
  5. On the Static Accounts page, click Create Username/Password.
  6. In the Create Username/Password panel, set AccessKey ID and AccessKey Secret. Then, click OK.
    On the Static Accounts page, the created pair of static username and password appears. The password is masked. Username and password
  7. In the Password column of the created pair of static username and password, click Display to view the password that corresponds to the username.

Create a vhost

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance is located.
  3. On the Instances page, click the name of your instance.
  4. In the left-side navigation pane, click vhosts.
  5. On the vhosts page, click Create vhost.
  6. In the Create vhost panel, enter a vhost name in the vhost Name field and click OK.
    Note
    The vhost name must comply with the following naming conventions:
    • The name can contain only letters, digits, hyphens (-), underscores (_), periods (.), and at signs (@).
    • The name must be 1 to 255 characters in length. Excess characters are automatically discarded.
    • After a vhost is created, you cannot modify its name.

Create an exchange

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance is located.
  3. On the Instances page, click the name of your instance.
  4. In the left-side navigation pane, click Exchanges.
  5. On the Exchanges page, click the drop-down arrow next to vhost. From the Change drop-down list, select the vhost in which you want to create an exchange. Then, click Create Exchange.
  6. In the Create Exchange panel, set Exchange Name, Type, and Internal. Then, click OK.
    Parameter Description
    Exchange Name The name of the exchange. The name of an exchange cannot start with amq. because amq. is used as a reserved field. For example, amq.test is an invalid name.
    Type The type of the exchange. Valid values:
    • direct: An exchange of this type routes a message to the queue whose binding key exactly matches the routing key of the message.
    • topic: This type is similar to the direct exchange type. However, the routing rule for a topic exchange is less demanding than that for a direct exchange. A topic exchange routes a message to one or more bound queues based on the result of fuzzy match or multi-condition match between the routing key of the message and the binding keys that are used to bind the queues to the exchange.
    • fanout: An exchange of this type routes all the received messages to all the queues bound to this exchange. You can use a fanout exchange to broadcast messages.
    • headers: This type is similar to the direct exchange type. The only difference is that a headers exchange routes messages based on headers attributes instead of routing keys. When you bind a headers exchange to a queue, you must configure binding attributes in the key-value format for the binding. When you send a message to a headers exchange, you must configure headers attributes in the key-value format for the message. After a headers exchange receives a message, it routes the message based on the matching between the headers attributes of the message and binding attributes of the bound queues.
    • x-jms-topic: This type applies to Java Message Service (JMS) applications that access Message Queue for RabbitMQ by using the JMS API provided by Message Queue for RabbitMQ. This type of exchange routes a message to queues based on the result of fuzzy match between the routing key and binding keys. Wildcards are used to support fuzzy match. For more information, see Overview.
    • x-delayed-message: You can declare an exchange of this type and set the x-delay header attribute of a message to specify the period of time after which the message will be delivered. The period of time is in milliseconds. The message will be delivered to the corresponding queue after the period of time specified by the x-delay header attribute elapses. The exchange routes messages based on the routing rule that corresponds to the exchange type specified by x-delayed-type.
    x-delayed-type If the exchange type is x-delayed-message, you must set this parameter to specify the routing rule for the exchange.
    Internal Specifies whether the exchange is an internal exchange. Default value: No. Valid values:
    • Yes: The exchange is bound to another exchange.
    • No: The exchange is bound to a queue.

Create a queue

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance is located.
  3. On the Instances page, click the name of your instance.
  4. In the left-side navigation pane, click Queues.
  5. On the Queues page, click the drop-down arrow next to vhost. From the Change drop-down list, select the vhost where you want to create a queue. Then, click Create Queue.
  6. In the Create Queue panel, enter a queue name in the Queue Name field and set Auto Delete. Click Advanced Settings and set the displayed parameters for the queue. Then, click OK.
    Parameter Description Notes
    Queue Name The name of the queue.
    • The name can contain only letters, digits, hyphens (-), underscores (_), periods (.), and at signs (@).
    • The name must be 1 to 255 characters in length.
    • After a queue is created, you cannot modify its name. If you want to modify its name, delete the queue and create another queue.
    • The name cannot start with amq. because amq. is used as a reserved field. For example, amq.test is an invalid name.
    Auto Delete Specifies whether the queue is automatically deleted after the last subscription from consumers to this 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 of 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 sent.
    • DeadLetterRoutingKey: the routing key of a dead-letter message. A dead-letter exchange sends a dead-letter message to the queue whose binding key matches the routing key of the dead-letter message.
    • MessageTTL: the period of time for which a message can stay in a queue before it expires. Unit: milliseconds. A message that is not consumed within the message TTL is a dead-letter message. The dead-letter message is sent to a dead-letter exchange.

Create a binding

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance is located.
  3. On the Instances page, click the name of your instance.
  4. In the left-side navigation pane, click Queues.
  5. On the Queues page, click the drop-down arrow next to vhost. From the Change drop-down list, select the vhost of the queue to which you want to bind an exchange. Find the queue, click More in the Actions column, and then select Bound as Destination.
  6. On the Bound as Destination tab of the Queue Details page, click Add Binding.
  7. In the Add Binding panel, set Source Exchange and Binding Key. Then, click Confirm.
    Note
    A binding key must comply with the following rules:
    • A binding key cannot contain Chinese characters.
    • For exchange types other than the topic exchange type, a binding key must be 1 to 255 characters in length, and can contain only letters, digits, hyphens (-), underscores (_), periods (.), and at signs (@).
    • For the topic exchange type, a binding key must be 1 to 255 characters in length, and can contain only letters, digits, hyphens (-), underscores (_), asterisks (*), periods (.), number signs (#), and at signs (@). A binding key can start or end with a number sign (#).

Create an AccessKey pair

When you use an SDK to send or receive messages, you must specify an instance, vhost, exchange, and queue. In addition, you must enter an AccessKey pair that you created in the Resource Access Management (RAM) console. An AccessKey pair consists of an AccessKey ID and an AccessKey secret. For more information, see Create an AccessKey pair.

What to do next

Use an SDK to send and receive messages