You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/11/05 02:30:57 UTC

[GitHub] beiwei30 closed pull request #176: Update docs about the delay exposure.

beiwei30 closed pull request #176: Update docs about the delay exposure.
URL: https://github.com/apache/incubator-dubbo-website/pull/176
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/en-us/user/demos/delay-publish.md b/docs/en-us/user/demos/delay-publish.md
index 06c42619..48007744 100644
--- a/docs/en-us/user/demos/delay-publish.md
+++ b/docs/en-us/user/demos/delay-publish.md
@@ -1,21 +1,32 @@
 # Delay publish service
 
-If your service need time to warm up.such as:initialization cache,or another reference resources has to be ready.so you can use the delay feature for delay publish service.
+If your services need time to warm up, such as: initialization cache or another reference resources has to be ready. You can use the delay feature to delay publishing services. We fine-tuned the service delay exposure logic in Dubbo 2.6.5, delaying the countdown of services that require delayed exposure until Spring initialization is complete. You won't be aware of this change while using Dubbo, so please be assured that use.
 
-## Delay five second publish
+## Prior to Dubbo-2.6.5
+### Delay five second publish
 
 ```xml
 <dubbo:service delay="5000" />
 ```
 
-## Delay until Spring initialization is complete before exposing the service
+### Delay until Spring initialization is complete before exposing the service
 ```xml
 <dubbo:service delay="-1" />
 ```
 
-### The initialization deadlock problem of Spring 2.x
+## Dubbo-2.6.5 and later
 
-#### Trigger condition
+All services will be exposed after Spring initialization is complete, and you don't need to configure delay if you don't need to delay exposing the service.
+
+### Delay five second publish
+
+```xml
+<dubbo:service delay="5000" />
+```
+
+## The initialization deadlock problem of Spring 2.x
+
+### Trigger condition
 
 The service has already published when `Spring` parse the `<dubbo:service />` element,but the `Spring` is still initializing other beans.If there is a request coming in, and the service implementation class has a call to `applicationContext.getBean ()` usage.
 
@@ -29,7 +40,7 @@ The service has already published when `Spring` parse the `<dubbo:service />` el
 
 This will cause the getBean thread to lock the singletonObjects first, then lock the beanDefinitionMap, and lock the singletonObjects again.The Spring initialization thread, the first lock beanDefinitionMap, then lock singletonObjects. Reverse lock thread deadlock, can not provide services, can not start.
 
-#### Avoid ways
+### Avoid ways
 
 1. It is highly recommended not to call applicationContext.getBean() in the service implementation class, all using Spring's beans using IoC injection.
 2. If you really want to tune getBean(), you can put the configuration of Dubbo Spring final loading.
diff --git a/docs/zh-cn/user/demos/delay-publish.md b/docs/zh-cn/user/demos/delay-publish.md
index 363bde55..37f74694 100644
--- a/docs/zh-cn/user/demos/delay-publish.md
+++ b/docs/zh-cn/user/demos/delay-publish.md
@@ -1,37 +1,49 @@
 # 延迟暴露
 
-如果你的服务需要预热时间,比如初始化缓存,等待相关资源就位等,可以使用 delay 进行延迟暴露。
+如果你的服务需要预热时间,比如初始化缓存,等待相关资源就位等,可以使用 delay 进行延迟暴露。我们在 Dubbo 2.6.5 版本中对服务延迟暴露逻辑进行了细微的调整,将需要延迟暴露(delay > 0)服务的倒计时动作推迟到了 Spring 初始化完成后进行。你在使用 Dubbo 的过程中,并不会感知到此变化,因此请放心使用。
 
-## 延迟 5 秒暴露服务
+## Dubbo-2.6.5 之前版本
+
+### 延迟到 Spring 初始化完成后,再暴露服务[^1]
+
+```xml
+<dubbo:service delay="-1" />
+```
+
+### 延迟 5 秒暴露服务
 
 ```xml
 <dubbo:service delay="5000" />
 ```
 
-## 延迟到 Spring 初始化完成后,再暴露服务 [^1]
+## Dubbo-2.6.5 及以后版本
+
+所有服务都将在 Spring 初始化完成后进行暴露,如果你不需要延迟暴露服务,无需配置 delay。
+
+#### 延迟 5 秒暴露服务
 
 ```xml
-<dubbo:service delay="-1" />
+<dubbo:service delay="5000" />
 ```
 
-### Spring 2.x 初始化死锁问题
+## Spring 2.x 初始化死锁问题
 
-#### 触发条件
+### 触发条件
 
 在 Spring 解析到 `<dubbo:service />` 时,就已经向外暴露了服务,而 Spring 还在接着初始化其它 Bean。如果这时有请求进来,并且服务的实现类里有调用 `applicationContext.getBean()` 的用法。
 
 1. 请求线程的 applicationContext.getBean() 调用,先同步 singletonObjects 判断 Bean 是否存在,不存在就同步 beanDefinitionMap 进行初始化,并再次同步 singletonObjects 写入 Bean 实例缓存。 
- 
+
     ![deadlock](../sources/images/lock-get-bean.jpg)  
 
 2. 而 Spring 初始化线程,因不需要判断 Bean 的存在,直接同步 beanDefinitionMap 进行初始化,并同步 singletonObjects 写入 Bean 实例缓存。
   
     ![/user-guide/images/lock-init-context.jpg](../sources/images/lock-init-context.jpg)  
- 
+
     这样就导致 getBean 线程,先锁 singletonObjects,再锁 beanDefinitionMap,再次锁 singletonObjects。  
 而 Spring 初始化线程,先锁 beanDefinitionMap,再锁 singletonObjects。反向锁导致线程死锁,不能提供服务,启动不了。  
 
-#### 规避办法
+### 规避办法
 
 1. 强烈建议不要在服务的实现类中有 applicationContext.getBean() 的调用,全部采用 IoC 注入的方式使用 Spring的Bean。
 2. 如果实在要调 getBean(),可以将 Dubbo 的配置放在 Spring 的最后加载。


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org