dubbo 远程调用
记得服务暴露的时候createServer()里 server = Exchangers.bind(url, requestHandler);
requestHandler在DubboProtocol里的实现如下:
private ExchangeHandler requestHandler = new ExchangeHandlerAdapter() {
@Override
public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
if (message instanceof Invocation) {
Invocation inv = (Invocation) message;
Invoker<?> invoker = getInvoker(channel, inv);
// need to consider backward-compatibility if it's a callback
if (Boolean.TRUE.toString().equals(inv.getAttachments().get(IS_CALLBACK_SERVICE_INVOKE))) {
String methodsStr = invoker.getUrl().getParameters().get("methods");
boolean hasMethod = false;
if (methodsStr == null || methodsStr.indexOf(",") == -1) {
hasMethod = inv.getMethodName().equals(methodsStr);
} else {
String[] methods = methodsStr.split(",");
for (String method : methods) {
if (inv.getMethodName().equals(method)) {
hasMethod = true;
break;
}
}
}
if (!hasMethod) {
logger.warn(new IllegalStateException("The methodName " + inv.getMethodName()
+ " not found in callback service interface ,invoke will be ignored."
+ " please update the api interface. url is:"
+ invoker.getUrl()) + " ,invocation is :" + inv);
return null;
}
}
RpcContext.getContext().setRemoteAddress(channel.getRemoteAddress());
return invoker.invoke(inv);
}
throw new RemotingException(channel, "Unsupported request: "
+ (message == null ? null : (message.getClass().getName() + ": " + message))
+ ", channel: consumer: " + channel.getRemoteAddress() + " --> provider: " + channel.getLocalAddress());
}

其中getInvoker()会去AbstractProtocol里的exporterMap通过serviceKey(facade.EchoService:20880)得到DubboExporter实例,最后得到RegistryProtocol$InvokerDelegete实例返回,最后调用inoker()方法,总结了下各invoker和export的持有关系如下:


dubbo 远程调用的更多相关文章
- Dubbo远程调用服务框架原理与示例
Dubbo 是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和 Spring框架无缝集成. 主要核心部件: Remoting: 网络通信框架 ...
- (转)dubbo远程调用细节
作者: 白文志 (来自开源社区) 服务提供者暴露一个服务的详细过程 上图是服务提供者暴露服务的主过程:首先ServiceConfig类拿到对外提供服务的实际类ref(如:HelloWorldImpl) ...
- 转: Dubbo远程调用服务框架原理与示例
Dubbo 是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和 Spring 框架无缝集成. 主要核心部件: Remoting: 网络通 ...
- Dubbo远程调用之公司内部提供的服务
公司内部提供的服务 一家对外提供服务的公司,例如百度,腾讯,阿里,京东,58 同城等,公司内部有多个事业群,事业部门,每个事业部门内部又有若干个子部门,子部门里面有多个不同的小组负责各自的业务.提供对 ...
- 架构师之路-在Dubbo中开发REST风格的远程调用
架构师之路:从无到有搭建中小型互联网公司后台服务架构与运维架构 http://www.roncoo.com/course/view/ae1dbb70496349d3a8899b6c68f7d10b 概 ...
- 【Rest】在Dubbo中开发REST风格的远程调用(RESTful Remoting)
目录 概述 REST的优点 应用场景 快速入门 标准Java REST API:JAX-RS简介 REST服务提供端详解 HTTP POST/GET的实现 Annotation放在接口类还是实现类 J ...
- 当当网开源Dubbox,扩展Dubbo服务框架支持REST风格远程调用
当当网近日开源了Dubbox项目,可为Dubbo服务框架提供多项扩展功能,包括REST风格远程调用.Kryo/FST序列化等等. 当当网架构部和技术委员会架构师沈理向InfoQ中文站介绍了Dubbox ...
- 在Dubbo中开发REST风格的远程调用(RESTful Remoting)
rest 在Dubbo中开发REST风格的远程调用(RESTful Remoting)
- alibaba远程调用框架dubbo原理
alibaba有好几个分布式框架,主要有:进行远程调用(类似于RMI的这种远程调用)的(dubbo.hsf),jms消息服务(napoli.notify),KV数据库(tair)等.这个框架/工具/产 ...
随机推荐
- 【转】Setting up SDL Extension Libraries on Code::Blocks 12.11
FROM: http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/window ...
- echarts legend 图例文字闪烁显示
最近同事小夏遇到一个需求:客户要求echarts图表上指定的图例文字闪烁显示. 先放一张图: 客户要求:待处理字样要闪动显示. 小夏一番百度之后,求助于我:快来看看,怎么有客户提这种百度都百度不到答案 ...
- [Luogu P3338] [ZJOI2014]力 (数论 FFT 卷积)
题面 传送门: 洛咕 BZOJ Solution 写到脑壳疼,我好菜啊 我们来颓柿子吧 \(F_j=\sum_{i<j}\frac{q_i*q_j}{(i-j)^2}-\sum_{i>j} ...
- 848.Shifting Letters——weekly contest 87
848. Shifting Letters 题目链接:https://leetcode.com/problems/shifting-letters/description/ 思路:O(N^2)复杂度过 ...
- python开发基础(二)运算符以及数据类型之str(字符串)
# encoding: utf-8 # module builtins # from (built-in) # by generator 1.147 """ Built- ...
- ubuntu 17.10 安装QQ
折腾一大堆 看报错信息 正在选中未选择的软件包 wine-qqintl:i386.(正在读取数据库 ... 系统当前共安装有 185429 个文件和目录.)正准备解包 wine-qqintl_0.1. ...
- php 检测敏感字
public function getMin($content){//调用接口 $content_url ="http://www.ju1.cn/index.php/Index/add.ht ...
- 【转】Lisp的本质
Lisp的本质: http://www.csdn.net/article/2012-11-22/2812113-The-Nature-Of-Lisp###
- 云原生haproxy 代理-ebpf
在如下网络层面下,代理(比如Envoy nginx )执行额外的L7策略(Health checks, service discovery, load balancing, mutual TLS),其 ...
- centos搭建dns服务
原文:(https://www.myjinji.top/articles/2020/04/02/1585800289945.html)[https://www.myjinji.top/articles ...