dubbo learning (four) check at startup

Check at startup

1. Configuration Introduction

By default, Dubbo will check whether the dependent services are available at startup, and throw an exception when it is unavailable to prevent Spring initialization from completing so that problems can be found early when it goes online. The default check="true".

You can turn off the check with check=“false”. For example, during the test, some services do not care, or there is a circular dependency, and one party must start it first.

In addition, if your Spring container is lazily loaded or the service is delayed through API programming, please turn off check. Otherwise, when the service is temporarily unavailable, an exception will be thrown and a null reference will be obtained. If check="false", it will always be Return the reference, when the service is restored, it can be automatically connected.

2. Testing

2.1 Stop user service

2.2 Start order service

 No provider available for the service 
 com.jxs.interfacedubbo.user.UserService from the url 
 zookeeper://127.0.0.1:2181/org.apache.dubbo.registry.RegistryService?
 application=order-
 consumer&dubbo=2.0.2&init=false&interface=com.jxs.interfacedubbo.user.UserS
 ervice&methods=getUserList&pid=16672&qos.enable=false&register.ip=192.168.4
 3.242&release=2.7.7&side=consumer&sticky=false&timeout=3000&timestamp=16048
 22050471 to the consumer 192.168.43.242 use dubbo version 2.7.7

Service failed to start

2.3 Add global configuration

#检查服务提供这个是否存在, true:必须要有服务提供者,否则启动失败,false:不检查服务提供这个,用的时候再检查
dubbo.consumer.check=false

2.3 For interface configuration

@DubboReference(check = false)
private UserService userService;

Guess you like

Origin blog.csdn.net/jinian2016/article/details/109560419