After you access Message Queue for RabbitMQ from an application, you must create resources, such as instances, a username/password pair, 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. After a subscription instance expires, it is automatically released. You can delete the records of expired instances from the console.
  1. Log on to the Message Queue for RabbitMQ console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Overview.
  4. On the page that appears, click Add Instance in the My Resources section.
  5. On the Message Queue for RabbitMQ Subscription page, configure basic parameters, select a subscription duration, and then click Buy Now.
  6. On the Confirm Order page, read the terms of service and select I have read and agree to Message Queue for RabbitMQ (Subscription) Terms of Service, and then click Pay.
  7. On the Purchase page, click Purchase.

Create a username/password pair

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Username/Password Management.
  4. On the Username/Password Management page, click Create Username/Password.
  5. In the Create Username/Password dialog box, enter an AccessKey ID in the AccessKey ID field, the AccessKey secret that corresponds to the AccessKey ID in the AccessKey Secret field, and an instance ID in the Instance ID field, and click OK.

Create a vhost

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the top navigation bar, select the region where your instance resides.
  3. In the left-side navigation pane, click vhosts.
  4. On the vhosts page, select an instance and click Create vhost.
  5. In the Create vhost dialog box, enter a vhost name in the vhost Name field and click Create.
    Note
    • The name can contain only letters, digits, hyphens (-), underscores (_), periods (.), and at signs (@).
    • It 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 top navigation bar, select the region where your instance resides.
  3. In the left-side navigation pane, click Exchanges.
  4. On the Exchanges page, select an instance and a vhost and click Create Exchange.
  5. In the Create Exchange dialog box, specify Exchange Name, Type, and Internal, and click Create.
    Parameter Description
    Exchange Name The name of the exchange. The name of an exchange cannot start with amq., which is used as a reserved field. For example, amq.test is an invalid name.
    Type The type of the exchange. Valid values:
    • 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.
    • direct: An exchange of this type routes a message to the queue whose binding key is exactly the same as the routing key of the message.
    • topic: This type is similar to the direct exchange type. An exchange of this type routes a message to one or more queues based on the fuzzy match or multi-condition match result between the routing key of the message and the binding keys of the current exchange.
    • headers: This type is similar to the direct exchange type. The only difference is that a headers exchange uses the headers attribute instead of a routing key of the message for route matching. 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 JMS applications that access Message Queue for RabbitMQ by using a JMS API provided by Message Queue for RabbitMQ. This type of exchange routes a message to queues based on the fuzzy match result between the routing key and binding keys. Wildcards are used to support fuzzy match. For more information, see Overview.
    Internal Specifies whether the exchange is an internal exchange. Valid values: true and false. Default value: false.
    • true: The exchange is bound to another exchange.
    • false: The exchange is bound to a queue.

Create a queue

  1. Log on to the Message Queue for RabbitMQ console.
  2. In the top navigation bar, select the region where your instance resides.
  3. In the left-side navigation pane, click Queues.
  4. On the Queues page, select an instance and a vhost and click Create Queue.
  5. In the Create Queue dialog box, specify Queue Name, Auto Delete, and Arguments, and click OK.
    pg_create_queue
    Parameter Description Remarks
    Queue Name The name of the queue.
    • The name can contain only letters, digits, hyphens (-), underscores (_), periods (.), and at signs (@).
    • It 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 a new queue.
    • The name of a queue cannot start with amq., which 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.
    Arguments Other parameters of the queue, such as the dead-letter exchange, dead-letter routing key, and message 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 message expiration time, in milliseconds. A message that is not consumed within 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 top navigation bar, select a region.
  3. In the left-side navigation pane, click Queues.
  4. On the Queues page, select an instance and a vhost. Find the queue for which you want to create a binding and click Bind in the Actions column.
  5. In the dialog box that appears, click Add Binding. Select an exchange for Source Exchange, enter a binding key in the Binding key field, and then click Confirm in the Actions column.

Create an AccessKey pair

When you call 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 RAM console. An AccessKey pair consists of an AccessKey ID and an AccessKey secret. For more information about how to create an AccessKey pair, see Create an AccessKey pair.

What to do next

Call an SDK to send and receive messages