edit-icon download-icon

Search for CID

Last Updated: Jan 30, 2018

OnsSubscribeSearch interface searches for the matching CID information according to Topic or CID information.

Usage

This interface searches for CID information according to Topic when the name of CID is unknown.

Request parameters

Name Type Required Description
OnsRegionId String Yes The region where the queried MQ is currently located. It can be obtained through the OnsRegionList method.
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.
Search String Yes A keyword for search, which can be Topic or PID.

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 Number of the current status
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 retrieving and printing the matching CID information with the search criterion of “CID_Mingduan”.

  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. OnsSubscriptionSearchRequest request = new OnsSubscriptionSearchRequest();
  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.setSearch("CID_Mingduan");
  27. try {
  28. OnsSubscriptionSearchResponse response=iAcsClient.getAcsResponse(request);
  29. List<OnsSubscriptionSearchResponse.SubscribeInfoDo> subscribeInfoDoList=response.getData();
  30. for(OnsSubscriptionSearchResponse.SubscribeInfoDo subscribeInfoDo:subscribeInfoDoList){
  31. System.out.println(subscribeInfoDo.getId()+" "+
  32. subscribeInfoDo.getChannelId()+" "+
  33. subscribeInfoDo.getChannelName()+" "+
  34. subscribeInfoDo.getOnsRegionId()+" "+
  35. subscribeInfoDo.getRegionName()+" "+
  36. subscribeInfoDo.getOwner()+" "+
  37. subscribeInfoDo.getConsumerId()+" "+
  38. subscribeInfoDo.getTopic()+" "+
  39. subscribeInfoDo.getStatus()+" "+
  40. subscribeInfoDo.getStatusName()+" "+
  41. subscribeInfoDo.getCreateTime()+" "+
  42. subscribeInfoDo.getUpdateTime());
  43. }
  44. } catch (ServerException e) {
  45. e.printStackTrace();
  46. } catch (ClientException e) {
  47. e.printStackTrace();
  48. }
  49. }
Thank you! We've received your feedback.