edit-icon download-icon

Get configuration

Last Updated: Jan 17, 2018

Description

Used to get the configuration from ACM when the service starts.

  1. public static String getConfig(String dataId, String group, long timeoutMs) throws ConfigException

Request parameters

Parameter name Parameter type Description
dataId String Configuration ID. Use a naming rule like package.class (for example, com.taobao.tc.refund.log.level) to ensure global uniqueness. It is recommended to indicate business meaning of the configuration in the “class” section. Use lower case for all characters. Use alphabetical letters and these four special characters (“.”, “:”, “-“, “_”) only. Up to 256 characters are allowed.
group String Configuration group. To ensure uniqueness, format such as product name: module name (for example, ACM:Test) is preferred. Use alphabetical letters and these four special characters (“.”, “:”, “-“, “_”) only. Up to 128 characters are allowed.
timeout string Length of configuration read time-out (in ms). Recommended value: 3000.

Return values

Parameter type Description
String Configuration value

Request example

  1. try {
  2. // Initialize the configuration service, and the console automatically obtains the following parameters through the sample code.
  3. ConfigService.init("${endpoint}", "${namespace}", "${accessKey}", "${secretKey}");
  4. // Actively get the configuration.
  5. String content = ConfigService.getConfig("${dataId}", "${group}", 3000);
  6. System.out.println(content);
  7. } catch (ConfigException e) {
  8. // TODO Auto-generated catch block
  9. e.printStackTrace();
  10. }

Exception specification

A ConfigException exception is thrown in case of a configuration read time-out or a network error.

Thank you! We've received your feedback.