You can call this operation to confirm the consumption status of messages.

Request structure

  • Request line

    DELETE /topics/TopicName/messages? ns=INSTANCE_ID&consumer=GID HTTP/1.1

    The following table lists the parameters in the request line.

    Parameter Required Description
    TopicName Yes The name of the destination topic to which a message is sent.
    ns No The instance ID. It is required for a new instance with a namespace. You can check whether the instance has a namespace on the Instances page of the console. Instances are classified into default instances and new instances depending on whether they have namespaces.
    • Default instance: has no namespace. All resource names in this default instance must be globally unique.
    • New instance: has a namespace. The resource names must be unique within this instance.
    For more information, see Updates.
    consumer Yes The group ID of a consumer.
  • Request content (XML format)

    The following table lists the parameters in the request content.

    Parameter Required Description
    ReceiptHandle Yes The message handle obtained through Operation for consuming messages. It is used to check whether a message is successfully consumed. The message handle can be used only once. The message handles obtained in consumption retries of the same message are different. The message handle must be used before NextConsumeTime.

Response structure

  • Successful request
    • Status line

      HTTP/1.1 204

    • Response content

      None

  • Failed request
    • Status line

      HTTP/1.1 404

    • Response content

      For more information, see Sample responses.

Examples

  • Sample requests
    <? xml version="1.0" encoding="UTF-8"? >
    <ReceiptHandles xmlns="http://mq.aliyuncs.com/doc/v1/">
    <ReceiptHandle>1E057D5E6EAD42A57993704EC383****-MTI5NT****</ReceiptHandle>
    <ReceiptHandle>1E057D5E6EAD42A57993704EC383****-MTI5NT****</ReceiptHandle>
    <ReceiptHandle>1E057D5E6EAD42A57993704EC383****-MTI5NT****</ReceiptHandle>
    </ReceiptHandles>       
  • Sample responses
    • The request content does not contain a handle.
          <? xml version="1.0" ? >
          <Error xmlns="http://mq.aliyuncs.com/doc/v1">
      <Code>MissingReceiptHandle</Code>
      <Message>ReceiptHandle is required. </Message>
      <RequestId>5DAEF2B9463541AD6E04490F</RequestId>
      <HostId>http://123.mqrest.cn-hangzhou.aliyuncs.com</HostId>
          </Error>               
    • The request handle is incorrect, which is adfadfadf.
          <? xml version="1.0" ? >
          <Errors xmlns="http://mq.aliyuncs.com/doc/v1">
      <Error>
              <ErrorCode>ReceiptHandleError</ErrorCode>
              <ErrorMessage>The receipt handle you provide is not valid. </ErrorMessage>
              <ReceiptHandle>adfadfadf</ReceiptHandle>
      </Error>
          </Errors>                
    • The request handle has expired, which indicates that the handle is used to confirm the message after NextConsumeTime.
          <? xml version="1.0" ? >
          <Errors xmlns="http://mq.aliyuncs.com/doc/v1">
      <Error>
              <ErrorCode>MessageNotExist</ErrorCode>
              <ErrorMessage>The receipt handle you provided has expired. </ErrorMessage>
              <ReceiptHandle>1E057D5E6EAD42A57993704EC383****-MTI5NT****</ReceiptHandle>
      </Error>
          </Errors>