You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by 海洋 <ha...@163.com> on 2019/01/21 02:50:44 UTC

About 2.7.0 Tag Route

Hi,


I'v found that 2.7.0 will support tag route. Where does the tag route be set?


Firstly, the TAG_KEY will be retrieved from the invocation. 
private <T> List<Invoker<T>> filterUsingStaticTag(List<Invoker<T>> invokers, URL url, Invocation invocation) {
    List<Invoker<T>> result = invokers;
// Dynamic param
String tag = StringUtils.isEmpty(invocation.getAttachment(TAG_KEY)) ? url.getParameter(TAG_KEY) :
            invocation.getAttachment(TAG_KEY);
The Invocation is created in InvokerInvocationHandler without attachment. I know that the RpcContext has the Attachment, and it will be copied to RpcInvocation in the filter chain, which behinds the Router. So, where to set it?
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return invoker.invoke(createInvocation(method, args)).recreate();
}

private RpcInvocation createInvocation(Method method, Object[] args) {
    RpcInvocation invocation = new RpcInvocation(method, args);
    if (RpcUtils.hasFutureReturnType(method)) {
        invocation.setAttachment(Constants.FUTURE_RETURNTYPE_KEY, "true");
invocation.setAttachment(Constants.ASYNC_KEY, "true");
}
return invocation;
}

Re:About 2.7.0 Tag Route

Posted by 海洋 <ha...@163.com>.
I see, 2.7.0 copies the attachment in AbstractClusterInvoker, before the router extension. 





At 2019-01-21 10:50:44, "海洋" <ha...@163.com> wrote:
>Hi,
>
>
>I'v found that 2.7.0 will support tag route. Where does the tag route be set?
>
>
>Firstly, the TAG_KEY will be retrieved from the invocation. 
>private <T> List<Invoker<T>> filterUsingStaticTag(List<Invoker<T>> invokers, URL url, Invocation invocation) {
>    List<Invoker<T>> result = invokers;
>// Dynamic param
>String tag = StringUtils.isEmpty(invocation.getAttachment(TAG_KEY)) ? url.getParameter(TAG_KEY) :
>            invocation.getAttachment(TAG_KEY);
>The Invocation is created in InvokerInvocationHandler without attachment. I know that the RpcContext has the Attachment, and it will be copied to RpcInvocation in the filter chain, which behinds the Router. So, where to set it?
>@Override
>public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
>return invoker.invoke(createInvocation(method, args)).recreate();
>}
>
>private RpcInvocation createInvocation(Method method, Object[] args) {
>    RpcInvocation invocation = new RpcInvocation(method, args);
>    if (RpcUtils.hasFutureReturnType(method)) {
>        invocation.setAttachment(Constants.FUTURE_RETURNTYPE_KEY, "true");
>invocation.setAttachment(Constants.ASYNC_KEY, "true");
>}
>return invocation;
>}