title: “Local Development and Test” lang: en ref: huawei-cloud permalink: /docs/users/local-develop-test/ excerpt: “Local Development and Test” last_modified_at: 2017-08-15T15:01:43-04:00 redirect_from:
{% include toc %}
This section describes how developers can locally develop and commission consumer and provider applications. Both service providers and consumers need to connect to the remote service center. Two methods of building Local ServiceCenter for local microservice commissioning are as follows:
Starting Local Service Center。
Starting Local Service Center Mock mechanism。
Service center is an important component in the microservice architecture, and is used for managing, registering, and detecting metadata and instance metadata. The logic relationship between the service center and microservice provider/consumer is as follows:
Step 1 Starting local service center, please refer to Setup Environment,
Step 2 After local service center is started, configure the service center address in the microservice.yaml file that stores SDK configuration information, as shown in the following example:
servicecomb: service: registry: address: http://127.0.0.1:30100 #Indicates the service center address and port number
Step 3 Develop service providers and consumers enable the microservice for local tests.
Step 1 Create the registry.yaml file for Local ServiceCenter
springmvctest: - id: "001" version: "1.0" appid: myapp #Commissioning service ID instances: endpoints: rest://127.0.0.1:8080
NOTE: The mock mechanism needs an API definition on its own. Currently, only local commissioning for service consumers is supported.
Step 2 Add the following code to the end of the Main function for service consumers.
public class xxxClient { public static void main(String[] args) { System.setProperty("local.registry.file", "/path/registry.yaml"); //your code System.clearProperty("local.registry.file"); }
NOTE: Set the second parameter of setProperty to the absolute path of registry.yaml file in the disk. The path separator depends on the system it is in.
Step 3 Develop service consumers and enable the microservice for local tests.