edit-icon download-icon

Configure Topic permission

Last Updated: Oct 17, 2018

This interface is exclusive for MQ Enterprise Platinum edition users. For more information, go to Enterprise Platinum Edition Purchase Page.

Usage

This interface is used for configuring read/write switches of the Topic based on the specified MQ region and the Topic name. It’s usually used for write-only or read-only scenarios.

Restrictions on primary accounts and sub-accounts

This interface is exclusively available for primary accounts by default, and cannot be used by RAM sub-accounts unless they are granted related permission.

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.
Topic String Yes The name of the Topic required to be configured, which must not be duplicate under the same user even in different regions.
Perm Integer Yes Controls the read/write permission of the Topic. 6 for “read/write access”, 4 for “read-only”, and 2 for “write-only”.

Response parameters

Name Type Description
RequestId String A public parameter unique for each request
HelpUrl String A help link
  • OnsTopicCreate: creates a Topic
  • OnsTopicList: views the list of Topics

Example

As a reference, this example shows the process of accessing from the end point China East, and setting the Topic “MingduanTest” to write-only mode.

  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. OnsTopicUpdateRequest request = new OnsTopicUpdateRequest();
  19. request.setAcceptFormat(FormatType.JSON);
  20. request.setTopic("MingduanTest");
  21. /**
  22. *OnsRegionId refers to the resource of the region of MQ required to be accessed by API.
  23. *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.
  24. */
  25. request.setOnsRegionId("daily");
  26. request.setPreventCache(System.currentTimeMillis());
  27. request.setPerm(4);//2 indicates "write-only"; 4 indicates "read-only"; 6 indicates "read/write supported".
  28. try {
  29. OnsTopicUpdateResponse response = IAcsClient.getAcsResponse(request);
  30. System.out.println(response.getRequestId());
  31. }
  32. catch (ServerException e) {
  33. e.printStackTrace();
  34. }
  35. catch (ClientException e) {
  36. e.printStackTrace();
  37. }
  38. catch (Exception e) {
  39. e.printStackTrace();
  40. }
  41. }
Thank you! We've received your feedback.