Closed gosenme closed 6 years ago
DubboProperties里面是一些provider和consumer的公共配置,其它配置可在注解@Service(provider端)和@Reference(consumer端)里面配置。
Is the @Service
annotation's filter property is actually used? I looked at the source code for dubbo and it doesn't seem to use it. Were you able to get this to work?
@adriancole hi, @Service annotation's filter property is inited in com.alibaba.dubbo.config.AbstractConfig#appendAnnotation, line 435. It works already in dubbo 2.6.0.
thanks. please ignore me on this one. I think I have a misunderstanding about how filter lifecycle works. I have found manually that a setter in trace filter was never called https://github.com/openzipkin/sleuth-webmvc-example/compare/add-dubbo-tracing
I guess I'd like to externalize the filter config as opposed to hard-code it on the annotation
@chickenlj mentioned to me this:
XML looks like this:
<!-- default timeout and filter for all services -->
<dubbo:consumer timeout="5000" filter="tracing" />
And annotation or spring boot, use .properties instead, for example:
dubbo.consumer.filter="tracing"
I tried in spring boot's properties file, even in a separate dubbo.properties file. Seems like filter should be something that we can do in spring boot style somehow (change without require user's code to change), ex via spring boot properties or autoconfiguration..
sorry forgot to mention above was @chickenlj
PS please hold an hour I was using a stale version of spring-cloud-sleuth.
We had to change sleuth as dubbo requires the bean name to exact match the extension name, so we changed sleuth to make sure it is exactly the same. I will update instructions on my end, and summarize progress in an hour.
ok so right now, as far as I can tell, there is no way to use spring boot (application.properties or autoconfig) to assign a global filter. The only way is external to spring boot, ex via a dubbo.properties file
dubbo.provider.filter=tracing
dubbo.consumer.filter=tracing
This works, but the problem is that in spring boot you will not see this and it won't be intuitive. For example if I hit the /autoconfig endpoint it will not know about this properties file.
It would be nice to be able to define a bean like this:
@GlobalFilter @Bean Filter tracing(Tracing tracing) {
TracingFilter result = new TracingFilter();
result.setTracing(tracing);
return tracing;
}
and have the above as the same as if it were set by properties "dubbo.provider.filter=tracing" and "dubbo.consumer.filter=tracing". However, I noticed that the extension loader for filter happens before hand because the filter itself is registered in meta-inf. In other words the statically initialized filter works instead.
For this reason, the simplest way out could just be allowing the spring boot starter here to define
spring.dubbo.provider.filter=tracing
spring.dubbo.consumer.filter=tracing
As long as spring is at least in control of the property names, we should be able to automatically insert the word tracing with spring-cloud-sleuth.
Does this make sense?
@adriancole Please switch to this starter : https://github.com/dubbo/dubbo-spring-boot-project , which is official starter, thanks!
@mercyblits I have been told both are official, but I suppose dubbo is the more official one now (due to apache I guess?)
@adriancole yes, https://github.com/dubbo/dubbo-spring-boot-project is more better :D
Duplicate of #72
DubboProperties里面支持的配置太少,怎么通过配置过滤掉dubbo默认的filter