All Products
Search
Document Center

ApsaraMQ for RocketMQ:OnsMessagePageQueryByTopic

Last Updated:Jun 10, 2026

Mengkueri semua paket yang disimpan dalam topik tertentu dalam rentang pengatur waktu tertentu per halaman.

Deskripsi operasi

Catatan

API operations provided by Alibaba Cloud are used to manage and query resources of Alibaba Cloud services. We recommend that you integrate these API operations only in management systems. Do not use these API operations in the core system of messaging services. Otherwise, system risks may occur.

  • If you do not know the ID or key of a message that you want to query, you can call this operation to query all messages that are stored in the topic within a specified time range. The results are displayed by page.

  • We recommend that you specify a short time range to query messages. If you specify a long time range, a large number of messages are returned. In this case, you cannot find the message that you want to query in an efficient manner. You can perform the following steps to query messages:

    1. Perform a paged query by specifying the topic, start time, end time, and number of entries to return on each page. If the topic contains messages, the information about the messages on the first page, total number of pages, and task ID are returned by default.

    2. Specify the task ID and a page number to call this operation again to query the messages on the specified page. The BeginTime, EndTime, and PageSize parameters do not take effect. By default, the system uses the values of these parameters that you specified in the request when you created the specified query task.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

mq:QueryMessage

get

Topic

acs:mq:{#regionId}:{#accountId}:{#TopicName}

Topic

acs:mq:{#regionId}:{#accountId}:{#InstanceId}%{#TopicName}

None
  • mq:OnsInstanceBaseInfo

Parameter permintaan

Parameter

Type

Required

Description

Example

Topic

string

Yes

Nama topik yang paketnya ingin Anda kueri.

test-mq_topic

BeginTime

integer

Yes

Awal rentang pengatur waktu yang akan dikueri. Nilai parameter ini adalah stempel waktu UNIX dalam milidetik. Jika Anda menentukan nilai valid untuk parameter TaskId di permintaan, parameter ini tidak berlaku. Sistem menggunakan nilai parameter BeginTime yang Anda tentukan di permintaan saat membuat tugas kueri yang ditentukan.

1570723200000

EndTime

integer

Yes

Akhir rentang pengatur waktu yang akan dikueri. Nilai parameter ini adalah stempel waktu UNIX dalam milidetik. Jika Anda menentukan nilai valid untuk parameter TaskId di permintaan, parameter ini tidak berlaku. Sistem menggunakan nilai parameter EndTime yang Anda tentukan di permintaan saat membuat tugas kueri yang ditentukan.

1570809600000

TaskId

string

No

ID tugas kueri. Saat pertama kali Anda memanggil operasi ini untuk mengkueri informasi tentang paket dalam topik tertentu dalam rentang pengatur waktu tertentu, parameter ini tidak diperlukan. Parameter ini diperlukan dalam kueri berikutnya untuk paket pada halaman tertentu. Anda dapat memperoleh ID tugas dari hasil yang dikembalikan dari kueri pertama.

0BC1310300002A9F000021E4D7A48346

CurrentPage

integer

Yes

Nomor halaman yang akan dikembalikan. Halaman dimulai dari halaman 1. Nilai valid: 1 hingga 50.

2

PageSize

integer

No

Jumlah entri yang akan dikembalikan pada setiap halaman. Nilai valid: 5 hingga 50. Nilai default: 20. Jika Anda menentukan nilai valid untuk parameter TaskId di permintaan, parameter ini tidak berlaku. Sistem menggunakan nilai parameter PageSize yang Anda tentukan di permintaan untuk membuat tugas kueri.

5

InstanceId

string

No

ID instans tempat paket yang ingin Anda kueri berada.

MQ_INST_111111111111_DOxxxxxx

Elemen respons

Element

Type

Description

Example

object

The data returned.

RequestId

string

The ID of the request. This parameter is a common parameter. Each request has a unique ID. You can use this ID to troubleshoot issues.

5DC2A47E-2B31-4722-96C8-FA59C9*****

MsgFoundDo

object

The information about the message that is queried.

CurrentPage

integer

The page number of the returned page.

1

MsgFoundList

object

OnsRestMessageDo

array<object>

The information about messages on the returned page. The information that is contained in this parameter is the same as the information that is returned by the OnsMessageGetByMsgId operation.

array<object>

StoreSize

integer

The size of the message. Unit: KB.

406

ReconsumeTimes

integer

The number of retries that were performed to send the message to consumers.

1

StoreTimestamp

integer

The time when the ApsaraMQ for RocketMQ broker stored the message. The value is a UNIX timestamp that represents the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

1570760999811

InstanceId

string

The ID of the instance

MQ_INST_111111111111_DOxxxxxx

MsgId

string

The ID of the message.

1E0578FE110F18B4AAC235C05F2*****

StoreHost

string

The ApsaraMQ for RocketMQ broker that stores the message.

11.193.***.***:10911

Topic

string

The topic to which the message belongs.

test-mq_topic

PropertyList

object

MessageProperty

array<object>

The attributes of the message.

object

Value

string

The value of the attribute.

TagA

Name

string

The name of the attribute. Valid values:

  • TRACE_ON: indicates whether a trace of the message exists.

  • KEYS: indicates the key of the message.

  • TAGS: indicates the tag of the message.

  • INSTANCE_ID: indicates the ID of the instance that contains the message.

For information about the terms that are used in ApsaraMQ for RocketMQ see Terms.

TAGS

BornTimestamp

integer

The time when the message was generated. The value is a UNIX timestamp that represents the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

1570760999721

BodyCRC

integer

The cyclic redundancy check (CRC) value of the message body.

914112295

BornHost

string

The producer client that generated the message.

42.120.***.***:59270

MaxPageCount

integer

The total number of returned pages.

400

TaskId

string

The ID of the query task. The first time you call this operation to query the messages that are sent to a specified consumer group within a specified time range, this parameter is returned. You can use the task ID to query the details of messages on other returned pages.

0BC1310300002A9F000021E4D7A48346

Contoh

Respons sukses

JSONformat

{
  "RequestId": "5DC2A47E-2B31-4722-96C8-FA59C9*****",
  "MsgFoundDo": {
    "CurrentPage": 1,
    "MsgFoundList": {
      "OnsRestMessageDo": [
        {
          "StoreSize": 406,
          "ReconsumeTimes": 1,
          "StoreTimestamp": 1570760999811,
          "InstanceId": "MQ_INST_111111111111_DOxxxxxx",
          "MsgId": "1E0578FE110F18B4AAC235C05F2*****",
          "StoreHost": "11.193.***.***:10911",
          "Topic": "test-mq_topic",
          "PropertyList": {
            "MessageProperty": [
              {
                "Value": "TagA",
                "Name": "TAGS"
              }
            ]
          },
          "BornTimestamp": 1570760999721,
          "BodyCRC": 914112295,
          "BornHost": "42.120.***.***:59270"
        }
      ]
    },
    "MaxPageCount": 400,
    "TaskId": "0BC1310300002A9F000021E4D7A48346"
  }
}

Kode kesalahan

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.