Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
Huawei Cloud Astro Canvas
Huawei Cloud Astro Zero
CodeArts Governance
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance (CCI)
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Cloud Transformation
Well-Architected Framework
Cloud Adoption Framework
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating an Instance

Function

This API is used to create an instance, and pay-per-use and yearly/monthly billing modes are supported.

Calling Method

For details, see Calling APIs.

URI

POST /v2/{engine}/{project_id}/instances

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

engine

Yes

String

Message engine.

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Instance name.

An instance name can contain 4 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

description

No

String

Description of an instance.

The description supports up to 1024 characters.

NOTE:
The backslash () and quotation mark (") are special characters for JSON messages. When using these characters in a parameter value, add the escape character () before the characters, for example, \ and ".

engine

Yes

String

Message engine. Value: reliability.

engine_version

Yes

String

Version of the message engine. The value can be 4.8.0.

storage_space

Yes

Integer

Storage space.

vpc_id

Yes

String

VPC ID.

To obtain it, log in to the VPC console and view the VPC ID on the VPC details page.

subnet_id

Yes

String

Subnet information.

To obtain it, log in to VPC console and click the target subnet on the Subnets page. You can view the network ID on the displayed page.

security_group_id

Yes

String

ID of the security group to which the instance belongs.

To obtain it, log in to the VPC console and view the security group ID on the security group details page.

available_zones

Yes

Array of strings

ID of the AZ where instance brokers reside and which has available resources. Obtain the AZ ID by referring to Listing AZ Information.

The parameter value cannot be empty or null. Check whether resources exist in the AZs.

A RocketMQ instance can be deployed in 1 AZ or at least 3 AZs. When specifying AZs for brokers, use commas (,) to separate multiple AZs.

product_id

Yes

String

RocketMQ instance flavors.

  • c6.4u8g.cluster.small: Max. 2,000 topics and 2,000 consumer groups per broker

  • c6.4u8g.cluster: Max. 4,000 topics and 4,000 consumer groups per broker

  • c6.8u16g.cluster: Max. 8,000 topics and 8,000 consumer groups per broker

  • c6.12u24g.cluster: Max. 12,000 topics and 12,000 consumer groups per broker

  • c6.16u32g.cluster: Max. 16,000 topics and 16,000 consumer groups per broker

ssl_enable

No

Boolean

Whether to enable SSL encryption for access.

  • true: enable

  • false: disable

storage_spec_code

Yes

String

Storage I/O specification.

  • dms.physical.storage.high.v2: high I/O disk

  • dms.physical.storage.ultra.v2: ultra-high I/O disk

enterprise_project_id

No

String

Enterprise project ID. This parameter is mandatory for an enterprise project account.

enable_acl

No

Boolean

Whether to enable access control.

ipv6_enable

No

Boolean

Indicates whether IPv6 is supported.

  • true: Yes

  • false: No

proxy_enable

No

Boolean

Whether to enable the proxy function.

  • true: Yes

  • false: No

enable_publicip

No

Boolean

Whether to enable public access. By default, public access is disabled.

  • true: enable

  • false: disable

publicip_id

No

String

ID of the EIP bound to the instance.

Use commas (,) to separate multiple EIP IDs.

This parameter is mandatory if public access is enabled (that is, enable_publicip is set to true).

broker_num

Yes

Integer

Number of brokers.

arch_type

No

String

Architecture type.

tls_mode

No

String

Security protocol used by an instance.

bss_param

No

BssParam object

Parameter related to the yearly/monthly billing mode.

If this parameter is left blank, the billing mode is pay-per-use by default. If this parameter is not left blank, the billing mode is yearly/monthly.

Table 3 BssParam

Parameter

Mandatory

Type

Description

is_auto_renew

No

Boolean

Whether auto renewal is enabled.

Options:

  • true: Auto renewal is enabled.

  • false: Auto renewal is not enabled.

By default, auto renewal is disabled.

charging_mode

No

String

Billing mode.

This parameter specifies a payment mode.

Options:

  • prePaid: yearly/monthly billing.

  • postPaid: pay-per-use billing.

The default value is postPaid.

is_auto_pay

No

Boolean

Specifies whether the order is automatically or manually paid.

Options:

  • true: The order will be automatically paid.

  • false: The order must be manually paid.

The default payment mode is manual.

period_type

No

String

Subscription period type.

Options:

  • month

  • year:

**This parameter is valid and mandatory only when chargingMode is set to prePaid. **

period_num

No

Integer

Subscribed periods.

Options:

  • If periodType is month, the value ranges from 1 to 9.

  • If periodType is year, the value ranges from 1 to 3.

**This parameter is valid and mandatory only when chargingMode is set to prePaid. **

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

instance_id

String

Instance ID.

Example Requests

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

POST https://{endpoint}/v2/reliability/{project_id}/instances

{
  "name" : "reliability-1751840557",
  "description" : "",
  "engine" : "reliability",
  "engine_version" : "4.8.0",
  "storage_space" : 600,
  "vpc_id" : "3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf",
  "subnet_id" : "0a0f1fcb-f019-458d-b9e5-301867394d50",
  "security_group_id" : "23c5977f-ff33-4b95-a73e-08d8a0bc4e6c",
  "available_zones" : [ "9f1c5806706d4c1fb0eb72f0a9b18c77" ],
  "product_id" : "c6.4u8g.cluster",
  "enterprise_project_id" : "0",
  "ssl_enable" : false,
  "storage_spec_code" : "dms.physical.storage.ultra.v2",
  "ipv6_enable" : false,
  "enable_publicip" : false,
  "publicip_id" : "",
  "broker_num" : 1
}

Example Responses

Status code: 200

Instance created successfully.

{
  "instance_id" : "8959ab1c-7n1a-yyb1-a05t-93dfc361b32d"
}

SDK Sample Code

The SDK sample code is as follows.

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.rocketmq.v2.region.RocketMQRegion;
import com.huaweicloud.sdk.rocketmq.v2.*;
import com.huaweicloud.sdk.rocketmq.v2.model.*;

import java.util.List;
import java.util.ArrayList;

public class CreateInstanceByEngineSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        RocketMQClient client = RocketMQClient.newBuilder()
                .withCredential(auth)
                .withRegion(RocketMQRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateInstanceByEngineRequest request = new CreateInstanceByEngineRequest();
        request.withEngine(CreateInstanceByEngineRequest.EngineEnum.fromValue("{engine}"));
        CreateInstanceByEngineReq body = new CreateInstanceByEngineReq();
        List<String> listbodyAvailableZones = new ArrayList<>();
        listbodyAvailableZones.add("9f1c5806706d4c1fb0eb72f0a9b18c77");
        body.withBrokerNum(1);
        body.withPublicipId("");
        body.withEnablePublicip(false);
        body.withIpv6Enable(false);
        body.withEnterpriseProjectId("0");
        body.withStorageSpecCode(CreateInstanceByEngineReq.StorageSpecCodeEnum.fromValue("dms.physical.storage.ultra.v2"));
        body.withSslEnable(false);
        body.withProductId(CreateInstanceByEngineReq.ProductIdEnum.fromValue("c6.4u8g.cluster"));
        body.withAvailableZones(listbodyAvailableZones);
        body.withSecurityGroupId("23c5977f-ff33-4b95-a73e-08d8a0bc4e6c");
        body.withSubnetId("0a0f1fcb-f019-458d-b9e5-301867394d50");
        body.withVpcId("3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf");
        body.withStorageSpace(600);
        body.withEngineVersion(CreateInstanceByEngineReq.EngineVersionEnum.fromValue("4.8.0"));
        body.withEngine(CreateInstanceByEngineReq.EngineEnum.fromValue("reliability"));
        body.withDescription("");
        body.withName("reliability-1751840557");
        request.withBody(body);
        try {
            CreateInstanceByEngineResponse response = client.createInstanceByEngine(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkrocketmq.v2.region.rocketmq_region import RocketMQRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkrocketmq.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = RocketMQClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(RocketMQRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateInstanceByEngineRequest()
        request.engine = "{engine}"
        listAvailableZonesbody = [
            "9f1c5806706d4c1fb0eb72f0a9b18c77"
        ]
        request.body = CreateInstanceByEngineReq(
            broker_num=1,
            publicip_id="",
            enable_publicip=False,
            ipv6_enable=False,
            enterprise_project_id="0",
            storage_spec_code="dms.physical.storage.ultra.v2",
            ssl_enable=False,
            product_id="c6.4u8g.cluster",
            available_zones=listAvailableZonesbody,
            security_group_id="23c5977f-ff33-4b95-a73e-08d8a0bc4e6c",
            subnet_id="0a0f1fcb-f019-458d-b9e5-301867394d50",
            vpc_id="3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf",
            storage_space=600,
            engine_version="4.8.0",
            engine="reliability",
            description="",
            name="reliability-1751840557"
        )
        response = client.create_instance_by_engine(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    rocketmq "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := rocketmq.NewRocketMQClient(
        rocketmq.RocketMQClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.CreateInstanceByEngineRequest{}
	request.Engine = model.GetCreateInstanceByEngineRequestEngineEnum().ENGINE
	var listAvailableZonesbody = []string{
        "9f1c5806706d4c1fb0eb72f0a9b18c77",
    }
	publicipIdCreateInstanceByEngineReq:= ""
	enablePublicipCreateInstanceByEngineReq:= false
	ipv6EnableCreateInstanceByEngineReq:= false
	enterpriseProjectIdCreateInstanceByEngineReq:= "0"
	sslEnableCreateInstanceByEngineReq:= false
	descriptionCreateInstanceByEngineReq:= ""
	request.Body = &model.CreateInstanceByEngineReq{
		BrokerNum: int32(1),
		PublicipId: &publicipIdCreateInstanceByEngineReq,
		EnablePublicip: &enablePublicipCreateInstanceByEngineReq,
		Ipv6Enable: &ipv6EnableCreateInstanceByEngineReq,
		EnterpriseProjectId: &enterpriseProjectIdCreateInstanceByEngineReq,
		StorageSpecCode: model.GetCreateInstanceByEngineReqStorageSpecCodeEnum().DMS_PHYSICAL_STORAGE_ULTRA,
		SslEnable: &sslEnableCreateInstanceByEngineReq,
		ProductId: model.GetCreateInstanceByEngineReqProductIdEnum().C6_4U8G_CLUSTER,
		AvailableZones: listAvailableZonesbody,
		SecurityGroupId: "23c5977f-ff33-4b95-a73e-08d8a0bc4e6c",
		SubnetId: "0a0f1fcb-f019-458d-b9e5-301867394d50",
		VpcId: "3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf",
		StorageSpace: int32(600),
		EngineVersion: model.GetCreateInstanceByEngineReqEngineVersionEnum().E_4_8_0,
		Engine: model.GetCreateInstanceByEngineReqEngineEnum().RELIABILITY,
		Description: &descriptionCreateInstanceByEngineReq,
		Name: "reliability-1751840557",
	}
	response, err := client.CreateInstanceByEngine(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.rocketmq.v2.region.RocketMQRegion;
import com.huaweicloud.sdk.rocketmq.v2.*;
import com.huaweicloud.sdk.rocketmq.v2.model.*;

import java.util.List;
import java.util.ArrayList;

public class CreateInstanceByEngineSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        RocketMQClient client = RocketMQClient.newBuilder()
                .withCredential(auth)
                .withRegion(RocketMQRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateInstanceByEngineRequest request = new CreateInstanceByEngineRequest();
        request.withEngine(CreateInstanceByEngineRequest.EngineEnum.fromValue("{engine}"));
        CreateInstanceByEngineReq body = new CreateInstanceByEngineReq();
        List<String> listbodyAvailableZones = new ArrayList<>();
        listbodyAvailableZones.add("9f1c5806706d4c1fb0eb72f0a9b18c77");
        body.withBrokerNum(1);
        body.withPublicipId("");
        body.withEnablePublicip(false);
        body.withIpv6Enable(false);
        body.withEnterpriseProjectId("0");
        body.withStorageSpecCode(CreateInstanceByEngineReq.StorageSpecCodeEnum.fromValue("dms.physical.storage.ultra.v2"));
        body.withSslEnable(false);
        body.withProductId(CreateInstanceByEngineReq.ProductIdEnum.fromValue("c6.4u8g.cluster"));
        body.withAvailableZones(listbodyAvailableZones);
        body.withSecurityGroupId("23c5977f-ff33-4b95-a73e-08d8a0bc4e6c");
        body.withSubnetId("0a0f1fcb-f019-458d-b9e5-301867394d50");
        body.withVpcId("3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf");
        body.withStorageSpace(600);
        body.withEngineVersion(CreateInstanceByEngineReq.EngineVersionEnum.fromValue("4.8.0"));
        body.withEngine(CreateInstanceByEngineReq.EngineEnum.fromValue("reliability"));
        body.withDescription("");
        body.withName("reliability-1751840557");
        request.withBody(body);
        try {
            CreateInstanceByEngineResponse response = client.createInstanceByEngine(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkrocketmq.v2.region.rocketmq_region import RocketMQRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkrocketmq.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = RocketMQClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(RocketMQRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateInstanceByEngineRequest()
        request.engine = "{engine}"
        listAvailableZonesbody = [
            "9f1c5806706d4c1fb0eb72f0a9b18c77"
        ]
        request.body = CreateInstanceByEngineReq(
            broker_num=1,
            publicip_id="",
            enable_publicip=False,
            ipv6_enable=False,
            enterprise_project_id="0",
            storage_spec_code="dms.physical.storage.ultra.v2",
            ssl_enable=False,
            product_id="c6.4u8g.cluster",
            available_zones=listAvailableZonesbody,
            security_group_id="23c5977f-ff33-4b95-a73e-08d8a0bc4e6c",
            subnet_id="0a0f1fcb-f019-458d-b9e5-301867394d50",
            vpc_id="3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf",
            storage_space=600,
            engine_version="4.8.0",
            engine="reliability",
            description="",
            name="reliability-1751840557"
        )
        response = client.create_instance_by_engine(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Creating a pay-per-use RocketMQ instance with the 4 vCPUs | 8 GB x 1 specifications and 600 GB storage space

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    rocketmq "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/rocketmq/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := rocketmq.NewRocketMQClient(
        rocketmq.RocketMQClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.CreateInstanceByEngineRequest{}
	request.Engine = model.GetCreateInstanceByEngineRequestEngineEnum().ENGINE
	var listAvailableZonesbody = []string{
        "9f1c5806706d4c1fb0eb72f0a9b18c77",
    }
	publicipIdCreateInstanceByEngineReq:= ""
	enablePublicipCreateInstanceByEngineReq:= false
	ipv6EnableCreateInstanceByEngineReq:= false
	enterpriseProjectIdCreateInstanceByEngineReq:= "0"
	sslEnableCreateInstanceByEngineReq:= false
	descriptionCreateInstanceByEngineReq:= ""
	request.Body = &model.CreateInstanceByEngineReq{
		BrokerNum: int32(1),
		PublicipId: &publicipIdCreateInstanceByEngineReq,
		EnablePublicip: &enablePublicipCreateInstanceByEngineReq,
		Ipv6Enable: &ipv6EnableCreateInstanceByEngineReq,
		EnterpriseProjectId: &enterpriseProjectIdCreateInstanceByEngineReq,
		StorageSpecCode: model.GetCreateInstanceByEngineReqStorageSpecCodeEnum().DMS_PHYSICAL_STORAGE_ULTRA,
		SslEnable: &sslEnableCreateInstanceByEngineReq,
		ProductId: model.GetCreateInstanceByEngineReqProductIdEnum().C6_4U8G_CLUSTER,
		AvailableZones: listAvailableZonesbody,
		SecurityGroupId: "23c5977f-ff33-4b95-a73e-08d8a0bc4e6c",
		SubnetId: "0a0f1fcb-f019-458d-b9e5-301867394d50",
		VpcId: "3db8490c-4d6d-4d8f-8d3f-047b0de4c5cf",
		StorageSpace: int32(600),
		EngineVersion: model.GetCreateInstanceByEngineReqEngineVersionEnum().E_4_8_0,
		Engine: model.GetCreateInstanceByEngineReqEngineEnum().RELIABILITY,
		Description: &descriptionCreateInstanceByEngineReq,
		Name: "reliability-1751840557",
	}
	response, err := client.CreateInstanceByEngine(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

200

Instance created successfully.

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback