Migrating Spring-based Application Configuration to Alibaba Cloud ACM

What Configuration Items Are Required to Be Migrated to ACM?

Timeliness: Comparison between Static and Dynamic Configuration Items

  • Software version number: The version number does not usually need to be changed after it is determined.
  • Log style: The layout of the log, for example, the timestamp, file name, and log level, typically does not need major changes.
  • Third-party software LicenseKey: Basically, it does not change. It is possible that a third-party software license is updated during use. However, such a configuration change can usually be handled by republishing the software.
  • PaaS platform connection string: For example, a database connection string contains the database name, username and password. This configuration item does not change unless the password is modified for the sake of compliance, or the database is changed.
  • Throttling parameters: Throttling parameters are generally not fixed. Throttling parameters, such as the response time (RT) threshold and peak transaction per second (TPS), are adjusted dynamically according to the actual workload pattern when the system is running.
  • Thresholds for monitoring and alerts: For example, the system generates an error alert when the transaction volume decreases by 20% in comparison with the previous period, and generates a critical alert when it decreases by 50%. For a monitoring system, the online service characteristics change frequently, so the thresholds are generally not fixed.
  • Log print level: For example, after something strange happens, we want to change the log print level from error to debug. We’d prefer dynamically adjusting this configuration item without restarting the application.
  • Multi-active disaster recovery: After a site suffers from a disaster, we definitely hope the service can be failed over as soon as possible. Therefore, this configuration item must take effect in seconds to minimize the asset loss.

Security: Comparison between Non-Sensitive and Sensitive Configuration Items

  • Software version number: It iterates with the product and contains no business attributes. Therefore, it is not sensitive.
  • Log style: This configuration item is associated with the future diagnostics of a program, and it is not sensitive.
  • Log print level: This configuration item determines the content of a log to be printed, and it is not sensitive.
  • Throttling parameters: Throttling parameters are mainly used to maintain internal application stability, and they are not sensitive.
  • Thresholds for monitoring and alerts: They mainly specify the alert precision for the business, and they are not sensitive.
  • Multi-active disaster recovery: This configuration item is generally associated with the primary-backup configuration and service sharding. It is not sensitive.
  • Third-party software LicenseKey: The disclosure of the license key may cause unauthorized use of it. It is sensitive.
  • PaaS platform connection string: For example, both internal and external users can easily log on to the business database and access sensitive business information with a database connection string. It is sensitive.

How Can I Migrate Spring-based Java Application Configuration?

The Original Pure Static File Scenario

@Configuration
@ComponentScan("com.alibaba")
@PropertySource("classpath:myApp.properties")
public class AppConfig {
@Value(value="${url}")
private String URL;
@Value(value="${dbuser}")
private String USER;
@Value(value="${driver}")
private String DRIVER;
@Value(value="${dbpassword}")
private String PASSWORD;
@Value(value="${appVersion}")
private String version;
}

The Mixed Configuration Scenario after the Start of the Configuration Migration

  • Add a record for the relevant configuration on the ACM console.
  • Add ACM SDK dependencies to the Java engineering package.
  • Slightly modify the code — add annotations to enable ACM to retrieve configurations.
<dependency> 
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-spring-context</artifactId>
<version>0.2.1- RC1</version>
</dependency>
@Configuration @ComponentScan("com.journaldev") 
@PropertySource("classpath:myApp.properties")
@EnableNacosConfig(globalProperties =
@NacosProperties(endpoint = "acm.aliyun.com", namespace = "xxx", accessKey = "xxx", secretKey = "xxx"))
@NacosPropertySource(dataId = "myApp.dbconfig.properties", autoRefreshed = true) public class AppConfig {
@Value(value="${url}") private String URL;
@Value(value="${dbuser}") private String USER;
@Value(value="${driver}") private String DRIVER;
@Value(value="${dbpassword}") private String PASSWORD;
@Value(value="${appVersion}")
private String version; public String getVersion() {
return version;
}
}

More Information

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why Decentralized Cloud is Important for the Web and Blockchain Industry

How do we relay messages at a high throughout between MicroServices? — Part 1

Most Useful Python Tricks 🐍

Changing the Way of Continuous Delivery with Docker (Part 2)

Lock Account after “x” amount of attempts — Spring Security

GSoC’20 Scorelabs: WEEK 1

12 Backend Development Tools by Alibaba

Meaning and Usage of __name__ == “__main__”

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

ISTIO, Docker for windows and minikube

How to Analysis or Audit your Elasticsearch Requests #

Geospatial indexing app with different backends using Spring Boot and Testcontainers

PART 1 Install of Saas based Appdynamics client on Linux for app server agent