You can call this operation to create a group of MQ for MQTT, that is, a group ID, on the MQTT broker.

Description

This operation is for users of Enterprise Platinum Edition instances only. For more information, go to Purchase of Enterprise Platinum Edition instances.

Scenarios

When new applications are launched, if you need to use an MQTT client for sending and receiving messages with existing topics, you must create a group ID in the console or by calling this operation.

Request parameters

Name Type Required Description
OnsPlatform String No The source of the request. By default, the request comes from the POP platform.
PreventCache Long Yes The parameter that is used for CSRF verification, which can be set to the current system time. Unit: ms
GroupId String Yes The ID of the MQTT group that you want to create.
InstanceId String Yes The ID of the MQTT instance that corresponds to the group ID that you want to create.

Response parameters

Name Type Description
RequestId String A common parameter. Each request has a unique ID.
HelpUrl String A help link.

Example

The following example shows how to create a group ID named GID_Test in the "cn-hangzhou" region.

 public static void main(String []args) {
            String regionId = "cn-hangzhou";
            String accessKey = "XXXXXXXXXXXXXXXXX";
            String secretKey = "XXXXXXXXXXXXXXXXX";
            IClientProfile profile= DefaultProfile.getProfile(regionId,accessKey,secretKey);
            IAcsClient iAcsClient= new DefaultAcsClient(profile);
          OnsMqttGroupIdCreateRequest request = new OnsMqttGroupIdCreateRequest();
          request.setPreventCache(System.currentTimeMillis());
          request.setAcceptFormat(FormatType.JSON);
          request.setGroupId("GID_Test");
          request.setInstanceId("aaaaa");
          try {
              OnsMqttGroupIdCreateResponse response=iAcsClient.getAcsResponse(request);
              System.out.println(response.getRequestId());
          } catch (ServerException e) {
              e.printStackTrace();
          } catch (ClientException e) {
              e.printStackTrace();
          }
      }