REST over Vertx

Configuration

The REST over Vertx communication channel runs in standalone mode, it can be started in the main function. In the main function, you need to initialize logs and load service configuration. The code is as follow:

import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.foundation.common.utils.Log4jUtils;

public class MainServer {
  public static void main(String[] args) throws Exception {
   Log4jUtils.init();// Log initialization
   BeanUtils.init(); // Spring bean initialization
  }
}

To use the REST over Vertx communication channel, add the following dependencies in the maven pom.xml file:

<dependency>
  <groupId>org.apache.servicecomb</groupId>
  <artifactId>transport-rest-vertx</artifactId>
</dependency>

The REST over Vertx related configuration items in the microservice.yaml file are described as follows:

Table 1-1 Configuration items for REST over Vertx

Configuration ItemDefault ValueRangeRequiredDescriptionRemark
servicecomb.rest.address0.0.0.0:8080-NoService listening addressOnly for providers
servicecomb.rest.server.thread-count1-NoServer's thread numberOnly for providers
servicecomb.rest.server.connection-limitInteger.MAX_VALUE-NoMax allowed client connectionsOnly for providers
servicecomb.rest.server.connection.idleTimeoutInSeconds60-NoTimeout for server's idle connectionThe idle connections will be recycled
servicecomb.rest.client.thread-count1-NoClient's thread numberOnly for consumers
servicecomb.rest.client.connection.maxPoolSize5-NoMax connection number of each poolconnection number = thread number * pool number * pool connection number
servicecomb.rest.client.connection.idleTimeoutInSeconds30-NoThe timeout of client idle connectionThe idle connections will be recycled
servicecomb.rest.client.connection.keepAlivetrue-NoUse long lived connection or not
servicecomb.request.timeout30000-NoRequest timeout
servicecomb.references.[ServiceName].transportrestNoThe transport type to accessOnly for consumers
servicecomb.references.[ServiceName].version-rulelatest-NoThe version of instance to accessOnly for consumers. The supported rules including latest,1.0.0+,1.0.0-2.0.2,or accurate version. For details, please refer to the service center interface description

Sample Code

An example of the configuration in the microservice.yaml file for REST over Vertx:

servicecomb:
  rest:
    address: 0.0.0.0:8080
    thread-count: 1
  references:
    hello:
      transport: rest
      version-rule: 0.0.1