Introduction to Dubbo Features

1. Address cache

The registration center is down, can the service still be accessed normally?

If the consumer has visited related services before, the address will be cached locally and will not go through the registration center, so it can be accessed.

2. Service timeout and retry

Use the timeout attribute to configure the timeout period. The default value is 1000, and the unit is milliseconds. It is recommended to configure it in the service provider, because only the service provider knows exactly how long it will take to execute.

Set the number of retries through the retries attribute. The default is 2 times.

//timeout 超时时间 单位毫秒  retries 重试次数
@Service(timeout = 3000,retries=0)

3. Multi-version settings

The version attribute is used in dubbo to set and call different versions of the same interface.

producer configuration

@Service(version="v2.0")
public class UserServiceImp12 implements UserService {...}

consumer configuration

@Reference(version = "v2.0")//远程注入
private UserService userService;

4. Load balancing strategy

 Service provider configuration

@Service(weight = 100)
public class UserServiceImp12 implements UserService {...}

consumer configuration

//@Reference(loadbalance = "roundrobin")
//@Reference(loadbalance = "leastactive")
//@Reference(loadbalance = "consistenthash")
@Reference(loadbalance = "random")//默认 按权重随机
private UserService userService;

5. Cluster fault tolerance

consumer configuration

@Reference(cluster = "failover")//远程注入
private UserService userService;

 6. Service downgrade

 consumer configuration

@Reference(mock =“ force :return null")//不再调用userService的服务
private UserService userService;

Guess you like

Origin blog.csdn.net/u012758488/article/details/129518415