Local Development and Test

Concept Description

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:

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:

Starting Local ServiceCenter

  • 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:

           address: #Indicates the service center address and port number
  • Step 3 Develop service providers and consumers enable the microservice for local tests.

Enable Local ServiceCenter Using the Mock Mechanism

  • Step 1 Create the registry.yaml file for Local ServiceCenter

       - id: "001"
         version: "1.0"
         appid: myapp #Commissioning service ID

    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

    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.