Updated on 2023-11-08 GMT+08:00

Dynamic Configuration Issues

Selecting Dynamic Configuration Type

Microservice engine 2.0's configuration center supports multiple formats such as TEXT and YAML.

  • Simple key-value configuration

    Use TEXT format. The keys in the configuration center and code are the same.

  • Many configurations

    Use YAML format. Ignore the configuration center key. All key-value pairs are defined in the YAML file.

    ServiceComb engine 1.x does not support YAML, but Spring Cloud Huawei does. Add the following configuration to the microservice Bootstrap:
    spring:
      cloud:
        servicecomb:
          config:
            fileSource: consumer.yaml # List of configuration items that need to be parsed based on YAML. Use commas (,) to separate multiple configuration items.
  • Initial use of ServiceComb engine 2.x

    You are advised to select the latest version of Spring Cloud Huawei, which contains more features and has been optimized based on historical issues.

Binding List Object Configuration

Some services use the list object configuration binding. For example:

@ConfigurationProperties("example.complex")
public class ComplexConfigurationProperties {
  private List<String> stringList;
  private List<Model> modelList;
  ... ...
}

For the list object, Spring Cloud queries related configuration items from only one PropertySource by default. If a PropertySource has some values of the configuration items, Spring Cloud does not query other values. For such services, ensure that configurations related to these list attributes have been placed in the configuration center. Do not place some elements in the configuration file or other elements in the configuration center.

This restriction is due to the atomicity of the list configuration – a configuration item (stringList or modelList in the code example) cannot be separated in different configuration files.