edit-icon download-icon

Query CID

Last Updated: Jan 30, 2018

OnsSubscribeGet interface queries the detailed information of the target CID.

Usage

To manage the subscription relations and retrieve the detailed information of the CIDs under an account, you can call this interface.

Request parameters

Name Type Required Description
OnsRegionId String Yes It specifies the region to be queried. The value is obtained through the OnsRegionList interface.
OnsPlatform String No The source of the request, which by default is POP platform.
PreventCache Long Yes It’s used for CSRF verification. Set it to the current system time.
ConsumerId String Yes CID of the subscribe relation to be queried
Topic String Yes Topic to be queried

Response parameters

Name Type Description
RequestId String A public parameter unique for each request
HelpUrl String A help link
Data List(SubscribeInfoDo) The set of queried subscription relations

SubscribeInfoDo data structure

Name Type Description
Id Long The index number of the subscription information in the database
channelId Integer The ID of the region where the Topic is located, including 0-ALIYUN, 1-CLOUD, 2, 3, and 4
channelName String The name of the region where the Topic is located. ALIYUN for Alibaba Cloud, CLOUD for Tmall Cloud…
onsRegionId Long The ID of the region where the Topic is located; obtained through the OnsRegionList method.
regionName String The name of the region where the Topic is located.
Owner String Owner of the publishing information
ConsumerId String ID of a consumption cluster
Topic String The Topic name
Status Long The current status
StatusName String The status name, including In Service, offline, and so on.
CreateTime Long Creation time
UpdateTime Long The last update time
  • OnsSubcribeCreate: creates a subscription relation
  • OnsSubcribeDelete: deletes a subscription relation
  • OnsSubscribeList: retrieves a list of subscription relations

Example

This example shows the process of querying and printing the information of a Consumer ID “CID_Mingduan” in the daily region.

  1. public static void main(String []args) {
  2. String regionId = "cn-hangzhou";
  3. String accessKey = "XXXXXXXXXXXXXXXXX";
  4. String secretKey = "XXXXXXXXXXXXXXXXX";
  5. String endPointName ="cn-hangzhou";
  6. String productName ="Ons";
  7. String domain ="ons.cn-hangzhou.aliyuncs.com";
  8. /**
  9. *Select Region based on the region you will access, and set the corresponding access point.
  10. */
  11. try {
  12. DefaultProfile.addEndpoint(endPointNameregionIdproductNamedomain);
  13. } catch (ClientException e) {
  14. e.printStackTrace();
  15. }
  16. IClientProfile profile= DefaultProfile.getProfile(regionIdaccessKeysecretKey);
  17. IAcsClient iAcsClient= new DefaultAcsClient(profile);
  18. OnsSubscriptionGetRequest request = new OnsSubscriptionGetRequest();
  19. /**
  20. *OnsRegionId refers to the resource of the region of MQ required to be accessed by API.
  21. *This value must be selected and configured by the list obtained through the OnsRegionList method because OnsRegionId is changing, and cannot be written as a fixed value.
  22. */
  23. request.setOnsRegionId("daily");
  24. request.setPreventCache(System.currentTimeMillis());
  25. request.setAcceptFormat(FormatType.JSON);
  26. request.setTopic("MingduanTest");
  27. request.setConsumerId("CID_Mingduan");
  28. try {
  29. OnsSubscriptionGetResponse response=iAcsClient.getAcsResponse(request);
  30. List<OnsSubscriptionGetResponse.SubscribeInfoDo> subscribeInfoDoList=response.getData();
  31. for(OnsSubscriptionGetResponse.SubscribeInfoDo subscribeInfoDo:subscribeInfoDoList){
  32. System.out.println(subscribeInfoDo.getId()+" "+
  33. subscribeInfoDo.getChannelId()+" "+
  34. subscribeInfoDo.getChannelName()+" "+
  35. subscribeInfoDo.getOnsRegionId()+" "+
  36. subscribeInfoDo.getRegionName()+" "+
  37. subscribeInfoDo.getOwner()+" "+
  38. subscribeInfoDo.getConsumerId()+" "+
  39. subscribeInfoDo.getTopic()+" "+
  40. subscribeInfoDo.getStatus()+" "+
  41. subscribeInfoDo.getStatusName()+" "+
  42. subscribeInfoDo.getCreateTime()+" "+
  43. subscribeInfoDo.getUpdateTime());
  44. }
  45. } catch (ServerException e) {
  46. e.printStackTrace();
  47. } catch (ClientException e) {
  48. e.printStackTrace();
  49. }
  50. }
Thank you! We've received your feedback.