ACM provides the capability of local ACM-SDK testing, which allows apps to be tested by retrieving configuration locally without remote connection to ACM. While building a local test environment, you can still access the public region in the Internet, however, other regions can only be accessed on the ECs of the same region, such as ACM's Shanghai Region, it can only be accessed on the ECS in Shanghai.

The ACM package currently supports Mac, Linux and Windows platforms, JDK 1.8 and later. The Function Comparison Between the ACM local package and the ACM website is as follows.

Items Compared ACM website ACM local
Configure actions Supported Yes-
Historical Version Yes Unsupported
Listen for queries Yes Unsupported
Push track Yes Unsupported
Namespaces Yes Unsupported

ACM deployment

  1. Download the ACM-server package locally (link: acm-server.tar.gz ).
  2. 2. Decompress the file, and the acm-server directory will be created under the current directory. directory.
    tar xzvf acm-server.tar.gz
  3. Enter the ACM-Server Directory, execute the startup script, run acm-server.
    cd acm-server/bin
    sudo sh catalina.sh run
  4. Access localhost:8080/diamond-server in the browser.

    The above logon interface indicates that acm-server is already started.

Create a configuration in the local console

  1. Enter localhost: 8080/diamond-server in the browser to enter the page.
  2. On the Configuration Management page, click New configuration.
  3. Enter the configured data ID, group ID, and content, and click Publish, this allows you to create a new configuration.

Querying the configuration in the local console

  1. On the Configuration Management page, enter the data ID and group that you want to query. ID, clickQuery.
    Note If you enter only the data ID, the query has the data ID All configurations. If you do not enter any query conditions, then the system queries all configurations.
  2. In the actions column of the query results list, click details.
  3. View the configuration content in the configuration content text box.

Modify the configuration in the local console

  1. In the actions column of the query results list, click Edit.
  2. Modify the configuration content in the configuration content text box, and click Publish.

Delete configurations

  1. In the actions column of the query results list, click Delete.
  2. The message "Are you sure you want to delete this icon?" is displayed. Click OK.

ACM-SDK testing

  1. Bind acm.aliyun.com domain name.

    Since ACM-SDK uses a maid domain name to connect the ACM, ACM-SDK Ability to access the local, need to modify the host file, bind the local domain name to the local IP 127.0.0.1.

    vim /etc/hosts
    Add 127.0.0.1 acm.aliyun.com
  2. Prepare ACM-SDK testing cases.

    Fill in the dataID and group of the created configuration in ACM-SDK. Successful retrieval of configuration indicates that the ACM local testing environment has been deployed successfully. The local test environment was deployed successfully.

    public class ACMTest {
     public static void main(String[] args) throws ConfigException, InterruptedException {
         // Initialize the configuration service, and the console automatically obtains the following parameters via the sample code. The input parameters are respectively endpoint, namespace, accessKey, secretKey (private key of ACM, rather than that of Alibaba Cloud)
         ConfigService.init("acm.aliyun.com", "", "", "");
         String content = ConfigService.getConfig("acm.test", "DEFAULT_GROUP", 6000);
         System.out.println(content);
         // Add listeners to the configuration during initialization, which calls back a notification.
         ConfigService.addListener("acm.test", "DEFAULT_GROUP", new ConfigChangeListener() {
             public void receiveConfigInfo(String configInfo) {
                 When the configuration is updated, use this callback function to output the newest value to the user.
                 // Remember not to make blocking operations by callback function, which otherwise would cause the notification thread to block.
                 System.out.println(configInfo);
             }
         });
         // sleep does not give way to the main thread
         Thread.sleep(100000);
     }
    }