// Tag request if (StringUtils.isNotEmpty(tag)) { // 自定义标签路由逻辑 ...
if (result == null) { logger.error("consumer tag:" + tag + "not match same tag or not match empty tag provider"); } } else { result = filterInvoker(invokers, invoker -> StringUtils.isEmpty(invoker.getUrl().getParameter(TAG_KEY))); } return result; }
We do that on purpose, you need to do some extra work to make the tag passed along the invoke chain. For example, you add a filter working before ContextFilter and save tag before it get removed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/** * ContextFilter set the provider RpcContext with invoker, invocation, local port it is using and host for * current execution thread. * * @see RpcContext */ @Activate(group = PROVIDER, order = -10000) publicclassContextFilterextendsListenableFilter { ... try { return invoker.invoke(invocation); } finally { // IMPORTANT! For async scenario, we must remove context from current thread, so we always create a new RpcContext for the next invoke for the same thread. RpcContext.removeContext(); RpcContext.removeServerContext(); } ... }