Provider cannot get the application parameter of consumer's url
在使用dubbo时,provider 无法在url中获取consumer的application,只能获取本服务的application,不知道是框架本身没有考虑到这点,还是故意这么设计的,建议你们在改造dubbo时,能够支持这一点,我们在使用过程中当服务调用方越来越多的时候,有的时候碰到问题时想快速排查哪个调用方的请求导致的问题,现在我们只能通过dubbo admin去找出哪些应用在调用,要一个一个去找对应的应用去排查问题,这么做太低效了,我们之前也有考虑过在每个请求方增加application的必填参数,但是这么做发现作为服务提供方要在每个dto中增加此参数,维护成本太大。 建议能够在url中带consumer的application,方便provider 维护接口
In DubboInvoker.doInvoke, there are some lines to add attachment to the invocation.
The application name from url parameter can be put into the attachments of invocation for sending to provider.
User can work with DubboProtocol.reply to print logs and so on.
#2377
- Configure "consumer.xml" file: "consumer.xml" already defines the application name attribute like this: <dubbo:application name="demo-provider"/>
- RpcContext: There is an field "attachments" in the "RpcContext.java" to support the developer to extend the field values in the form of a key-value.
- in the ComsumerContextFilter, we use the invoke() method to call the RpcContext.setAttachment() method as follows: RpcContext.setAttachment(Constants.APPLICATION_KEY,invoker.getUrl().getParameter("application"))
- The Provider can take the application name from the RpcContext: RpcContext.getContext().getAttachment("application name")
Hi, pls look at here for more info: https://github.com/dubbo/dubbo-samples It is recommended to pass the application information of the consumer through the attachment.