dubbo tutorial specification

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.8.4</version>
</dependency>
(2)使用xml进行dubbo provider和consumer的配置
(3)dubbo 统一配置 xml格式如下
<dubbo:application name="${dubbo.application.name}" />
<dubbo:registry protocol="${dubbo.registry.protocol}" address="${dubbo.registry.address}" username="${dubbo.admin.username}" password="${dubbo.admin.password}" group="${dubbo.registry.group}" timeout="${dubbo.registry.timeout}" file="${dubbo.registry.file}"/>
<dubbo:provider timeout="${dubbo.provider.timeout}" token="${dubbo.provider.token}" />
<dubbo:protocol name="${dubbo.protocol.name}" dispatcher="${dubbo.protocol.dispatcher}" threadpool="${dubbo.protocol.threadpool}" threads="${dubbo.protocol.threads }" accepts="${dubbo.protocol.accepts}" port="${dubbo.protocol.port}" charset="${dubbo.protocol.charset}" payload="${dubbo.protocol.payload}" />
  1. Configure the dubbo application name
  2. Configure the registry: address configures the zookeeper address; group configures the dubbo group; timeout configures the registry connection timeout; file configures the location of the registry cache file
  3. Configures the dubbo provider: timeout configures the provider timeout Time; token configuration provider token
  4. Configuration protocol Dubbo commonly uses the following protocols
   (1) The dubbo protocol adopts a single long connection and NIO asynchronous communication, which is suitable for small data volume and large concurrent service calls, and the number of service consumer machines is much larger than that of the service The number of provider machines.
   (2) RMI adopts the JDK standard java.rmi. * Implementation, using blocking short connection and JDK standard serialization method.
   (3) The Hessian protocol is used to integrate Hessian services. The bottom layer of Hessian uses Http communication and Servlet to expose services. By default, Dubbo embeds Jetty as a server implementation.
(4) dubbo provider configuration
<dubbo:service interface="com.shenma.paulfrank.service.LogService" ref="logService" loadbalance="${dubbo.service.loadbalance}" />
loadbalance The load balancing strategy that should be adopted is common There are the following types
  : 1. roundrobin polling, set the round robin ratio according to the weight after the convention, there is a problem of slow providers accumulating requests, for example: the second machine is very slow, but it does not hang, when the request is transferred to the second machine It gets stuck there, and over time, all requests get stuck on the second channel.
  2. leastActive is the minimum number of active calls, the same active number is random, and the active number refers to the difference between the counts before and after the call. Make the slow provider receive fewer requests, because the slower the provider's count difference before and after the call will be larger.
  3. ConsistentHash Consistent Hash, requests with the same parameters are always sent to the same provider. When a certain provider hangs, the request originally sent to the provider will be spread to other providers based on virtual nodes, and will not cause drastic changes.
(5) dubbo consumer configuration
<dubbo:reference id="orderService" interface="com.shenma.orderApi.api.OrderService" timeout="${dubbo.consumer.timeout}" retries="${dubbo.consumer.retries }"/>
  1. timeout consumer timeout
  2.

  1. The registry should configure the cache file location, that is, the file item should specify
  2. The number of retries of the dubbo consumer is recommended to be set to 0. If the consumer system has been configured idempotent, it can also be arranged by itself.
  3. If you encounter the error of no provider, you can go to the dubbo admin to check whether the dubbo service exists

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326097979&siteId=291194637