Last night, I thought deeply the timing of Dubbo expose service. And I also 
think It is more reasonable to expose service after Spring ready.

-xiaobo

在 2018年11月1日,上午11:12,Ian Luo <ian....@gmail.com<mailto:ian....@gmail.com>> 写道:

pls. always loop in dev@dubbo.apache.org<mailto:dev@dubbo.apache.org> to 
discuss :)

On Thu, Nov 1, 2018 at 11:07 AM 田 小波 
<tianxiaobo....@outlook.com<mailto:tianxiaobo....@outlook.com>> wrote:
Last night, I thought deeply the timing of Dubbo expose service. I think It is 
more reasonable to expose service after Spring ready.

-xiaobo

在 2018年11月1日,上午10:39,Ian Luo <ian....@gmail.com<mailto:ian....@gmail.com>> 写道:

> 当代码修改后,由于 afterPropertiesSet 不再对 delay 进行校验。导致当 delay > 0,且
supportedApplicationListener = true 时,export 会被 onApplicationEvent 调用,而不是
afterPropertiesSet。这会造成服务被延迟到 Spring 容器就绪后的 delay
毫秒暴露,而不是像之前被延迟到afterPropertiesSet 调用 export 后的 delay 毫秒暴露。

I think this behavior is expected. The reason is, the best timing for Dubbo to 
count down delay for exposing service is when Spring container is ready, then 
this timing should be the moment when spring context gets refreshed, since at 
this moment, all beans are settled, and are ready for wiring in their 
dependencies. If it happens earlier, say, at the moment after properties set, 
then Dubbo may fail to expose service because it depends on other spring bean.

To conclude, Dubbo should start to expose services until spring context gets 
refreshed, no matter delay or no-delay is configured. Unfortunately in order to 
keep backward compatibility, considering not all spring versions support 
context refresh callback, we have to start to expose services after properties 
set if we find application listener is not supported, and hope Dubbo service 
can be exposed normally.

I hope this can clarify the behavior.

-Ian.



On Thu, Nov 1, 2018 at 10:03 AM Zonghai Shang 
<y...@apache.org<mailto:y...@apache.org>> wrote:
Hi,

> 我重新看了代码和文档,发现确实存在一个延迟暴露的问题。这里先列举 Dubbo 的延迟暴露策略:
> delay = null 或 delay = -1 :延迟到 Spring 容器就绪后暴露服务,由 onApplicationEvent 调用
export 暴露服务
> delay > 0 :延迟指定毫秒后暴露服务,时间从 afterPropertiesSet 调用 export
时算起,此时由 afterPropertiesSet 调用 export暴露服务

> 当代码修改后,由于 afterPropertiesSet 不再对 delay 进行校验。导致当 delay > 0,且
supportedApplicationListener = true 时,export 会被 onApplicationEvent 调用,而不是
afterPropertiesSet。这会造成服务被延迟到 Spring 容器就绪后的 delay
毫秒暴露,而不是像之前被延迟到afterPropertiesSet 调用 export 后的 delay 毫秒暴露。

> 这是我目前所发现的问题,不知道和你说的是不是同一个。

Yes, you are right.

yiji

田 小波 <tianxiaobo....@outlook.com<mailto:tianxiaobo....@outlook.com>> 
于2018年11月1日周四 上午1:25写道:

> Hi,
>
> 我重新看了代码和文档,发现确实存在一个延迟暴露的问题。这里先列举 Dubbo 的延迟暴露策略:
>
> delay = null 或 delay = -1 :延迟到 Spring 容器就绪后暴露服务,由 onApplicationEvent 调用
> export 暴露服务
> delay > 0 :延迟指定毫秒后暴露服务,时间从 afterPropertiesSet 调用 export
> 时算起,此时由 afterPropertiesSet 调用 export 暴露服务
>
> 当代码修改后,由于 afterPropertiesSet 不再对 delay 进行校验。导致当 delay > 0,且
> supportedApplicationListener = true 时,export 会被 onApplicationEvent 调用,而不是
> afterPropertiesSet。这会造成服务被延迟到 Spring 容器就绪后的 delay
> 毫秒暴露,而不是像之前被延迟到afterPropertiesSet 调用 export 后的 delay 毫秒暴露。
>
> 这是我目前所发现的问题,不知道和你说的是不是同一个。
>
> - xiaobo
>
> 在 2018年10月31日,下午10:43,Zonghai Shang <y...@apache.org<mailto:y...@apache.org>> 
> 写道:
>
> Hi,
>
> 我认为这种修改会造成延迟暴露的bug。
> 如果要在容器启动10秒后才进行服务暴露怎么办?
> 原始意图delay= 10000表示10秒后执行。
>
> I think this modification will cause a delay in the exposure of the bug.
> What if you want to expose the service 10 seconds after the spring
> container started ?
> The original intention delay = 10000 represents execution after 10
> seconds.
>
> public synchronized void export() {
>     if (delay != null && delay > 0) {
>        // should be delay, eg: 1 seconds
>         delayExportExecutor.schedule(new Runnable() {
>             @Override
>             public void run() {
>                 doExport();
>             }
>         }, delay, TimeUnit.MILLISECONDS);
>     } else {
>         doExport();
>     }
> }
>
> yiji
>
> Ian Luo <ian....@gmail.com<mailto:ian....@gmail.com>> 于2018年10月31日周三 下午5:50写道:
>
>> good good study, day day up. Looking forward to your contribution :)
>>
>> On Wed, Oct 31, 2018 at 4:43 PM 田 小波 
>> <tianxiaobo....@outlook.com<mailto:tianxiaobo....@outlook.com>> wrote:
>>
>> > Yes, in fact, It is a plan. I'm learning Dubbo code by writing blogs
>> way,
>> > It can make me understand Dubbo code deeply. So, I need to finish my
>> blogs
>> > first before doing other thing.
>> >
>> > 在 2018年10月31日,下午3:11,Ian Luo <ian....@gmail.com<mailto:ian....@gmail.com>> 
>> > 写道:
>> >
>> > sounds like a plan :)
>> >
>> > Thanks,
>> > -Ian.
>> >
>> > On Wed, Oct 31, 2018 at 2:53 PM 田 小波 
>> > <tianxiaobo....@outlook.com<mailto:tianxiaobo....@outlook.com>>
>> wrote:
>> >
>> >> OK. I will read these articles carefully and think about how to enhance
>> >> them next month or later. Please wait.
>> >>
>> >> 在 2018年10月31日,下午2:26,Ian Luo 
>> >> <ian....@gmail.com<mailto:ian....@gmail.com>> 写道:
>> >>
>> >> Excellent post. You may consider to enhance
>> >> http://dubbo.apache.org/zh-cn/blog/introduction-to-dubbo-spi.html and
>> >> http://dubbo.apache.org/zh-cn/blog/introduction-to-dubbo-spi-2.html.
>> >>
>> >> -Ian.
>> >>
>> >> On Wed, Oct 31, 2018 at 1:36 PM 田 小波 
>> >> <tianxiaobo....@outlook.com<mailto:tianxiaobo....@outlook.com>>
>> wrote:
>> >>
>> >>> Luo Ian:
>> >>>
>> >>> I will contribute more for Dubbo community in the future. I'm going to
>> >>> submit a new PR to dubbo-website after my Dubbo blogs are finished. I
>> am
>> >>> now hastening to write blogs, and two blogs has bean finished. I will
>> >>> finish remaining blogs next month. The first blog "Dubbo 源码分析 - SPI 机制
>> >>> <https://www.cnblogs.com/nullllun/p/9758682.html>" has bean published
>> >>> on cnblogs.com<http://cnblogs.com/>. You may read it and give me some 
>> >>> guidance if you have
>> >>> interest and time, thanks.
>> >>>
>> >>> Best wishes,
>> >>> -xiaobo.
>> >>>
>> >>>
>> >>>
>> >>> 在 2018年10月31日,上午10:08,Ian Luo 
>> >>> <ian....@gmail.com<mailto:ian....@gmail.com>> 写道:
>> >>>
>> >>> XiaoBo,
>> >>>
>> >>> Nice! Pls. consider contributing more to the community in the future.
>> >>>
>> >>> Recently, I have bean writing a series of blogs about Dubbo
>> >>>
>> >>> Pls. share the link with the community (send email to
>> >>> dev@dubbo.apache.org<mailto:dev@dubbo.apache.org>) once you finish :) 
>> >>> You can also consider to
>> post
>> >>> your article to Dubbo's website [1]. It will become another pull
>> request
>> >>> from you by the way :)
>> >>>
>> >>> Thanks,
>> >>> -Ian.
>> >>>
>> >>> 1. https://github.com/apache/incubator-dubbo-website
>> >>>
>> >>>
>> >>> On Tue, Oct 30, 2018 at 9:20 PM 田 小波 
>> >>> <tianxiaobo....@outlook.com<mailto:tianxiaobo....@outlook.com>>
>> wrote:
>> >>>
>> >>>> Luo lan:
>> >>>>     Thanks to merge my PR. It is my first PR, I feel very exciting.
>> >>>> Recently, I have bean writing a series of blogs about Dubbo. And, I
>> expect
>> >>>> to submit more PR for Dubbo. Lastly, I hope Dubbo get more
>> popularity.
>> >>>>     Best wishes.
>> >>>>
>> >>>> 在 2018年10月30日,下午5:14,Ian Luo 
>> >>>> <ian....@gmail.com<mailto:ian....@gmail.com>> 写道:
>> >>>>
>> >>>> Xiaobo,
>> >>>>
>> >>>> I notice that you've already updated pull request. Now the change
>> looks
>> >>>> good, and I've merged your pull request.
>> >>>>
>> >>>> Thanks,
>> >>>> -Ian.
>> >>>>
>> >>>> On Tue, Oct 30, 2018 at 11:19 AM Ian Luo 
>> >>>> <ian....@gmail.com<mailto:ian....@gmail.com>> wrote:
>> >>>>
>> >>>>> Xiaobo,
>> >>>>>
>> >>>>> Would you mind to take a look at the comments I dropped on pull
>> >>>>> request 2686 [1] you proposed? Basically I think we could
>> completely remove
>> >>>>> isDelay method, if you agree with this idea, pls. follow up to
>> enhance your
>> >>>>> pull request.
>> >>>>>
>> >>>>> Thanks,
>> >>>>> -Ian.
>> >>>>>
>> >>>>> 1. https://github.com/apache/incubator-dubbo/pull/2686
>> >>>>>
>> >>>>
>> >>>>
>> >>>
>> >>
>> >
>
>
>


Reply via email to