All Products
Search
Document Center

Simple Message Queue (formerly MNS):BatchDeleteMessage

Last Updated:Aug 22, 2026

Menghapus beberapa pesan dari sebuah Antrian.

Otorisasi

Secara default, hanya Akun Alibaba Cloud yang dapat memanggil operasi ini. Pengguna RAM dapat memanggilnya setelah diberikan izin terkait. Tabel berikut menjelaskan informasi otorisasi untuk operasi ini. Untuk informasi selengkapnya, lihat Kebijakan dan contoh otorisasi.

Item

Value

Operasi API

BatchDeleteMessage

Action

mns:BatchDeleteMessage

Resource

acs:mns:$region:$accountid:/queues/$queueName/messages

Deskripsi

Operasi ini memungkinkan Anda menghapus hingga 16 pesan sekaligus dari sebuah Antrian dalam satu permintaan. Receipt handle dari setiap pesan yang akan dihapus harus disertakan dalam permintaan tersebut.

Untuk meningkatkan efisiensi, kami menyarankan menggunakan operasi ini bersama dengan operasi BatchReceiveMessage. Permintaan penghapusan beberapa pesan mencakup beberapa subpermintaan, dan beberapa di antaranya mungkin gagal. Kode status HTTP 204 hanya dikembalikan jika semua subpermintaan berhasil. Jika beberapa subpermintaan gagal, periksa pesan error dalam respons masing-masing.

Permintaan

Permintaan terdiri atas bagian-bagian berikut:

  • Baris permintaan

    DELETE /queues/$queueName/messages HTTP/1.1

  • Header permintaan khusus operasi

    Tidak ada.

  • Badan permintaan

    Badan permintaan menggunakan format XML dan harus menyertakan receipt handle dari setiap pesan yang ingin dihapus.

Respons

Respons terdiri atas bagian-bagian berikut:

  • Kode status HTTP

    HTTP/1.1 204 NoContent

  • Header respons khusus operasi

    Tidak ada.

  • Badan respons

    Tidak ada.

Contoh

Contoh permintaan

DELETE  /queues/$queueName/messages HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXA****

<?xml version="1.0" encoding="UTF-8"?>
<ReceiptHandles xmlns="http://mns.aliyuncs.com/doc/v1/">
    <ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
    <ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
    <ReceiptHandle>1-ODU4OTkzNDU5NS0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
</ReceiptHandles>            

Contoh respons

  • Contoh respons sukses jika semua pesan berhasil dihapus

        HTTP/1.1 204 No Content
        x-mns-request-id:512B2A634403E52B1956****
        x-mns-version: 2015-06-06                  
  • Contoh respons jika beberapa pesan gagal dihapus

        HTTP/1.1 404
        Connection:close
        Content-Type=text/xml;charset=utf-8
        Content-Length:500
        x-mns-request-id:512B2A634403E52B1956****
        x-mns-version: 2015-06-06
    
        <?xml version="1.0" encoding="UTF-8"?>
        <Errors xmlns="http://mns.aliyuncs.com/doc/v1/">
        <Error>
            <ErrorCode>MessageNotExist</ErrorCode>
            <ErrorMessage>Message not exist.</ErrorMessage>
            <ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
        </Error>
        <Error>
            <ErrorCode>MessageNotExist</ErrorCode>
            <ErrorMessage>Message not exist.</ErrorMessage>
            <ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
        </Error>
        </Errors>                    

Kode error

Kode errorKode status HTTPPesan errorDeskripsi
QueueNotExist404The queue name you provided does not exist.Antrian yang ditentukan tidak ada. Verifikasi nama Antrian dalam URI permintaan.
InvalidArgument400The value of Element should between Low and High seconds/bytes.Nilai parameter berada di luar rentang yang valid. Periksa parameter permintaan terhadap rentang nilai yang diizinkan.
ReceiptHandleError400The receipt handle you provided is not valid.Receipt handle telah kedaluwarsa karena NextVisibleTime telah lewat, atau handle yang sudah usang digunakan. Konsumsi ulang pesan tersebut untuk mendapatkan receipt handle baru.