edit-icon download-icon

Publish configuration

Last Updated: Apr 17, 2018

## Description

It publishes ACM configurations automatically with program to reduce operation and maintenance costs with automation.

Note: It uses the same publishing interface to create or modify a configuration. If the specified configuration doesn’t exist, then it creates a configuration. If the specified configuration exists, then it updates the configuration.

public static boolean publishConfig(String dataId, String group, String content) throws ConfigException

Request parameters

Parameter name Parameter type Description
dataId String Configuration ID. Naming convention similar to package.class (for example com.taobao.tc.refund.log.level) is used for ensuring the global uniqueness We recommended that you define the class part based on business meaning. All characters must be in lower case. Only English characters and four special characters (“. ”, “: ”, “-”, “_”) are allowed. It must not exceed 256 bytes.
group String Configuration group. We recommend that you use product name: module name (for example ACM:Test) to ensure the uniqueness. Only English characters and four special characters (“. ”, “: ”, “-”, “_”) are allowed. It must not exceed 128 bytes.
content string Configuration content. It must not exceed 100K bytes.

Response parameters

Parameter type Description
boolean If the publishing is successful

Request example

try {
    // Initialize the configuration service. Retrieves the following parameters in console with sample code
    ConfigService.init("${endpoint}", "${namespace}", "${accessKey}", "${secretKey}");
    // Actively retrieves configuration
    boolean isPublishOk = ConfigService.publishConfig("${dataId}", "${group}", "${content}");
    System.out.println(isPublishOk);
} catch (ConfigException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

Exceptions

In case of reading configuration timeout or network issues, ConfigException exception is thrown.

Thank you! We've received your feedback.