Mi Galaxy EMQ Book

createQueue()


Create Queue

Parameters CreateQueueRequest

queueName : String : required

The name of the new queue should include only letters (case sensitive) and numbers, such as testQueue1

queueAttribute : QueueAttribute : optional

The attributes of the new queue, which contains optional user-defined attributes, are as follows:

  1. DelaySeconds:int:optional
    Delay time. After the message enters the queue, it becomes visible after the delay time.
    default value: 0
    Legal Range: [0, 900]
  2. InvisibilitySeconds: int: optional
    Invisible time. After a message is received by the user, if not deleted by the user in time, will become visible again after the expiration of invisible time
    Default: 30
    Legal Range: [0, 43200]
  3. receiveMessageWaitSeconds:int:optional
    The timeout for long polling. For long polling the request is blocked until the Message is read or a timeout is returned.
    Defaults to 0, which indicates short polling. Default value: 0
    Legal Range: [0, 20]
  4. receiveMessageMaximumNumber: int: optional
    The maximum number of message items that a receiveMessage request can obtain
    Default value: 100
    Legal Range: [1, 100]
  5. messageRetentionSeconds:int:optional
    Message retention time. The expiration time of the message, uses (sendTimestamp + delayTime) as the start time for the calculation.
    Messages that exceed the retention time, whether or not they have been ACK, may be deleted. Default value: 4 days
    Legal Range: [60 seconds, 14 days]
  6. messageMaximumBytes: int: optional
    The maximum size and message attributes of message that the queue allows to be sent will be included in the count
    Default Value: 256 KB
    Legal Range: (0, 256 KB)
  7. partitionNumber:int:optional The number of partitions contained within the 1ueue, can not be set by user. When the QPS is high or the number of messages accumulated is high, you need to contact the administrator to increase the number of partitions so as not to affect queue performance.
    Default Value: 4, ID 0-3
    Legal Range: [1, 256]
  8. userAttributes:map< String, string >: Optional
    User-defined attributes
queueQuota : QueueQuota : optional

Queue quota contains the qps of read and write requests for the queue. In addition to quota limits for a single queue, there is a limit to the sum of the quotas for all queues for a single user and the total number of queues that can be created.

- throughput : Throughput : optional

Sets the number of read/write request quotas per second for the queue. Includes 2 fields:

  1. readQps : long : optional
    Indicates the maximum number of read access requests to the queue per second, in units of req/sec
    Default: 50
    Legal Range: (0, 100000)
  2. writeQps : long : optional
    Indicates the maximum number of write access requests to the queue per second, in units of req/sec
    Default Value: 50
    Legal Range: (0, 100000]
enablePriority : boolean : optional

Set whether the queue enable message priority. See PriorityQueue for details. Default Value: False

topicQueue : boolean : optional

Sets whether the queue is a topicQueue. See TopicQueue for details. Default Value: False

defaultTagName : String : optional

Setting this attribute to create an alias for the queue's defaultTag, and use the defaultTag in subsequent operations. After creating an alias, the user can still use "" (empty) to refer to the defaultTag. For a detailed explanation of defaultTag, see Tag-related Operations

Return CreateQueueResponse

queueName : String

The name of the successfully created queue. All subsequent requests should pass in the queueName returned here as an argument, such as getQueueInfo(),sendMessage()

Note: The queueName returned here is not the same as in CreateQueueRequest, and the returned name is prefixed with the organization id. If the orgId is1111, this returns 1111/testQueue1

queueAttribute : QueueAttribute

Queue attributes

queueQuota : QueueQuota

Queue quota

enablePriority : boolean

Whether the queue enable Message priority.

topicQueue : boolean

Whether the queue is a topicQueue

defaultTagName : String

Alias for queue's defaultTag, empty by default

deleteQueue()


Delete Queue

Parameters DeleteQueueRequest

queueName : String : required

The name of the queue to be deleted

Note: The queueName here should be set to return in CreateQueueResponse. The following method is the same with no further prompt

Return void

purgeQueue()


Clear all the messages in the queue, and keep the queue's attributes unchanged

Parameters PurgeQueueRequest

queueName : String : required

The name of the queue to be cleared

Method return void