Following the previous article, this article mainly says the configuration and use of Dubbo

The configuration principle

Configure access parameters in the service provider. Because the service provider is more aware of the various parameters of the service.

Close inspection

Dubbo will check whether the dependent services are available at startup. If not, it will throw an exception to prevent Spring initialization from being completed, so that problems can be detected when it goes online. By default, check=true. Check =”false” to turn off the check, for example, when testing, some services do not care, or there is a loop dependency, one party must start first.

Example 1: Disable the startup check of a service

<dubbo:reference interface="com.foo.BarService" check="false" />

Example 2: Close registry startup check

<dubbo:registry check="false" />

Check that the registry exists and is running when the service is started by default. An error occurs when the registry is not started.

To share with you the video tutorial, you can directly click to watch the video content covers:

  • From the beginning of the basic step-by-step detailed explanation of the concept of RPC, PRC in the distributed application of the important role.
  • Dubbo distributed services framework application basics.
  • Traditional applications to distributed and microservices shift thinking.
  • Characteristics of the Dubbo protocol.
  • Detailed development process of Dubbo distributed service, implementation and deployment of Dubbo service, service management of Zookeeper, etc.

Watch online: www.bilibili.com/video/BV1Sk.

Data download: www.bjpowernode.com/javavideo/1…

Retry count

The consumer accesses the provider, and if the access fails, the switch retries the access to another server, but the retries bring a longer delay. The access time becomes longer, resulting in poor user experience. Multiple attempts to access the server may succeed. Retries =”2″ can be used to set the number of retries (excluding the first).

timeout

An indeterminate intermediate state (timeout) can occur in the call due to network or server unreliability. The timeout period must be set to prevent client resources (threads) from being suspended due to timeouts.

Timeout: Timeout time for invoking the remote service (milliseconds)

Dubbo consumers

Dubbo server

The version number

Each interface should have a version number defined to allow for incompatible upgrades. When an interface has different implementations, an implementation class is used early in the project, and a new implementation class of the interface is created later. Distinguish between different interface implementations using Version.

Copy zK-node-shop-userService to zK-node-shop-multi-userService

Reproduction UserServiceImpl. Java

The address information in UserServiceImpl2 is added with the content of 2 to distinguish the original data.

Dubbo configuration file userservice-provider.xml

Add the version flag

Copy the ZK-Node-shop-web project as zK-Node-shop-multi-Web

(3) ShopService interface

(4) ShopServiceImpl interface implementation class

(5) Add methods to the ShopController class

(6) Modify the consumer profile

The test application

1. Start ZooKeeper

2. Start tomcat

3. Access services

Compare the address in the order, the address to view the user information is different content