Dubbo源码学习总结系列二 dubbo-rpc远程调用模块
dubbo本质是一个RPC框架,我们首先讨论这个骨干中的骨干,dubbo-rpc模块。
主要讨论一下几部分内容:
一、此模块在dubbo整体框架中的作用;
二、此模块需要完成的需求功能点及接口定义;
三、DubboProtocol实现细节;
四、其他协议实现;
一、此模块在dubbo整体框架中的作用
Protocol 是框架中的核心层,也就是只要有 Protocol + Invoker + Exporter 就可以完成非透明的 RPC 调用,然后在 Invoker 的主过程上 Filter 拦截点。它抽象了动态代理,只包含一对一的调用,不关心集群的管理。
二、此模块需要完成的需求功能点及接口定义
远程调用层:封装 RPC 调用,以 Invocation
, Result
为中心,扩展接口为 Protocol
,Invoker
, Exporter。
远程调用模块实现Protocol,Invoker, Exporter等上层协议接口定义,实现DubboProtocol协议的上层实现,以及DubboCodec类(dubbo编码)实现;封装了Hession协议、RMI协议、Http协议、WebService协议、Rest协议、Thrift等协议的实现;抽象了动态代理,只包含一对一的调用,不关心集群的管理。
核心接口定义有:
协议接口:Protocol
package com.alibaba.dubbo.rpc; import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.common.extension.Adaptive;
import com.alibaba.dubbo.common.extension.SPI; /**
* Protocol. (API/SPI, Singleton, ThreadSafe)
*/
@SPI("dubbo")
public interface Protocol { /**
* Get default port when user doesn't config the port.
*
* @return default port
*/
int getDefaultPort(); /**
* Export service for remote invocation: <br>
* 1. Protocol should record request source address after receive a request:
* RpcContext.getContext().setRemoteAddress();<br>
* 2. export() must be idempotent, that is, there's no difference between invoking once and invoking twice when
* export the same URL<br>
* 3. Invoker instance is passed in by the framework, protocol needs not to care <br>
*
* @param <T> Service type
* @param invoker Service invoker
* @return exporter reference for exported service, useful for unexport the service later
* @throws RpcException thrown when error occurs during export the service, for example: port is occupied
*/
@Adaptive
<T> Exporter<T> export(Invoker<T> invoker) throws RpcException; /**
* Refer a remote service: <br>
* 1. When user calls `invoke()` method of `Invoker` object which's returned from `refer()` call, the protocol
* needs to correspondingly execute `invoke()` method of `Invoker` object <br>
* 2. It's protocol's responsibility to implement `Invoker` which's returned from `refer()`. Generally speaking,
* protocol sends remote request in the `Invoker` implementation. <br>
* 3. When there's check=false set in URL, the implementation must not throw exception but try to recover when
* connection fails.
*
* @param <T> Service type
* @param type Service class
* @param url URL address for the remote service
* @return invoker service's local proxy
* @throws RpcException when there's any error while connecting to the service provider
*/
@Adaptive
<T> Invoker<T> refer(Class<T> type, URL url) throws RpcException; /**
* Destroy protocol: <br>
* 1. Cancel all services this protocol exports and refers <br>
* 2. Release all occupied resources, for example: connection, port, etc. <br>
* 3. Protocol can continue to export and refer new service even after it's destroyed.
*/
void destroy(); }
调用者接口Invoker:
package com.alibaba.dubbo.rpc; import com.alibaba.dubbo.common.Node; /**
* Invoker. (API/SPI, Prototype, ThreadSafe)
*
* @see com.alibaba.dubbo.rpc.Protocol#refer(Class, com.alibaba.dubbo.common.URL)
* @see com.alibaba.dubbo.rpc.InvokerListener
* @see com.alibaba.dubbo.rpc.protocol.AbstractInvoker
*/
public interface Invoker<T> extends Node { /**
* get service interface.
*
* @return service interface.
*/
Class<T> getInterface(); /**
* invoke.
*
* @param invocation
* @return result
* @throws RpcException
*/
Result invoke(Invocation invocation) throws RpcException; }
发布者接口Exporter:
package com.alibaba.dubbo.rpc; /**
* Exporter. (API/SPI, Prototype, ThreadSafe)
*
* @see com.alibaba.dubbo.rpc.Protocol#export(Invoker)
* @see com.alibaba.dubbo.rpc.ExporterListener
* @see com.alibaba.dubbo.rpc.protocol.AbstractExporter
*/
public interface Exporter<T> { /**
* get invoker.
*
* @return invoker
*/
Invoker<T> getInvoker(); /**
* unexport.
* <p>
* <code>
* getInvoker().destroy();
* </code>
*/
void unexport(); }
请求调用上下文接口Invocation:
package com.alibaba.dubbo.rpc; import java.util.Map; /**
* Invocation. (API, Prototype, NonThreadSafe)
*
* @serial Don't change the class name and package name.
* @see com.alibaba.dubbo.rpc.Invoker#invoke(Invocation)
* @see com.alibaba.dubbo.rpc.RpcInvocation
*/
public interface Invocation { /**
* get method name.
*
* @return method name.
* @serial
*/
String getMethodName(); /**
* get parameter types.
*
* @return parameter types.
* @serial
*/
Class<?>[] getParameterTypes(); /**
* get arguments.
*
* @return arguments.
* @serial
*/
Object[] getArguments(); /**
* get attachments.
*
* @return attachments.
* @serial
*/
Map<String, String> getAttachments(); /**
* get attachment by key.
*
* @return attachment value.
* @serial
*/
String getAttachment(String key); /**
* get attachment by key with default value.
*
* @return attachment value.
* @serial
*/
String getAttachment(String key, String defaultValue); /**
* get the invoker in current context.
*
* @return invoker.
* @transient
*/
Invoker<?> getInvoker(); }
dubbo-rpc-api模块定义了基本接口,给出了默认实现类:
Protocol接口的默认实现为AbstractProtocol,AbstractProxyProtocol类
(1)AbstractProtocol实现了destory()方法,主要逻辑为:循环销毁invoker、exporter。
(2)AbstractProxyProtocol给出了export()和refer()的默认实现,分别返回AbstractExport和AbstractInvoker实例。
三、DubboProtocol实现细节(dubbo-rpc-default);
Dubbo 缺省协议采用单一长连接和 NIO 异步通讯,适合于小数据量大并发的服务调用,以及服务消费者机器数远大于服务提供者机器数的情况。
反之,Dubbo 缺省协议不适合传送大数据量的服务,比如传文件,传视频等,除非请求量很低。
特性
缺省协议,使用基于 mina 1.1.7
和 hessian 3.2.1
的 tbremoting 交互。
- 连接个数:单连接
- 连接方式:长连接
- 传输协议:TCP
- 传输方式:NIO 异步传输(默认netty)
- 序列化:Hessian2 二进制序列化
- 适用范围:传入传出参数数据包较小(建议小于100K),消费者比提供者个数多,单一消费者无法压满提供者,尽量不要用 dubbo 协议传输大文件或超大字符串。
- 适用场景:常规远程服务方法调用
核心类:DubboProtocol
1、实现了export()方法,此方法实现了服务提供者接口的对外发布,返回Exporter对象,用于得到invoker并调用,以及销毁exporter对象。
实现逻辑为:
(1)判断是否需要创建stub支持,需要则在stubServiceMethodsMap缓存中存储dubbo.stub.event.methods方法名;
Stub本地存根:远程服务后,客户端通常只剩下接口,而实现全在服务器端,但提供方有些时候想在客户端也执行部分逻辑,比如:做 ThreadLocal 缓存,提前验证参数,调用失败后伪造容错数据等等,此时就需要在 API 中带上 Stub,客户端生成 Proxy 实例,会把 Proxy 通过构造函数传给 Stub 1,然后把 Stub 暴露给用户,Stub 可以决定要不要去调 Proxy。
(2)创建或更新(reset)远程服务,并放到serverMap缓存中;创建远程服务逻辑为:给传入的URL设置默认属性,包括:当服务通道关闭时发送只读事件(channel.readonly.sent),开启心跳检测(维护长连接),设置默认编码方式为dubbo,创建绑定url和请求处理类requestHandler的ExchangeServer并返回;
public <T> Exporter<T> export(Invoker<T> invoker) throws RpcException {
URL url = invoker.getUrl(); // export service.
String key = serviceKey(url);
DubboExporter<T> exporter = new DubboExporter<T>(invoker, key, exporterMap);
exporterMap.put(key, exporter); //发布一个本地存根服务,用于分发事件(猜测,不确定)
Boolean isStubSupportEvent = url.getParameter(Constants.STUB_EVENT_KEY, Constants.DEFAULT_STUB_EVENT);
Boolean isCallbackservice = url.getParameter(Constants.IS_CALLBACK_SERVICE, false);
if (isStubSupportEvent && !isCallbackservice) {
String stubServiceMethods = url.getParameter(Constants.STUB_EVENT_METHODS_KEY);
if (stubServiceMethods == null || stubServiceMethods.length() == 0) {
if (logger.isWarnEnabled()) {
logger.warn(new IllegalStateException("consumer [" + url.getParameter(Constants.INTERFACE_KEY) +
"], has set stubproxy support event ,but no stub methods founded."));
}
} else {
stubServiceMethodsMap.put(url.getServiceKey(), stubServiceMethods);
}
} openServer(url);
optimizeSerialization(url);
return exporter;
} private void openServer(URL url) {
// find server.
String key = url.getAddress();
//client can export a service which's only for server to invoke
boolean isServer = url.getParameter(Constants.IS_SERVER_KEY, true);
if (isServer) {
ExchangeServer server = serverMap.get(key);
if (server == null) {
serverMap.put(key, createServer(url));
} else {
// server supports reset, use together with override
server.reset(url);
}
}
} private ExchangeServer createServer(URL url) {
// 当服务通道关闭时,发送只读事件,默认为True
url = url.addParameterIfAbsent(Constants.CHANNEL_READONLYEVENT_SENT_KEY, Boolean.TRUE.toString());
// 默认开启心跳检测
url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT));
//约定传输服务为netty实现
String str = url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_SERVER); if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str))
throw new RpcException("Unsupported server type: " + str + ", url: " + url);
//默认使用dubbo序列化
url = url.addParameter(Constants.CODEC_KEY, DubboCodec.NAME);
ExchangeServer server;
try {
//创建信息交换接口实现类,默认为HeaderExchanger类实例,
server = Exchangers.bind(url, requestHandler);
} catch (RemotingException e) {
throw new RpcException("Fail to start server(url: " + url + ") " + e.getMessage(), e);
}
str = url.getParameter(Constants.CLIENT_KEY);
if (str != null && str.length() > 0) {
Set<String> supportedTypes = ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions();
if (!supportedTypes.contains(str)) {
throw new RpcException("Unsupported client type: " + str);
}
}
return server;
} private void optimizeSerialization(URL url) throws RpcException {
//得到序列化优化参数,通常为kryo或fst,将序列化实现设置为制定类实例
String className = url.getParameter(Constants.OPTIMIZER_KEY, "");
if (StringUtils.isEmpty(className) || optimizers.contains(className)) {
return;
} logger.info("Optimizing the serialization process for Kryo, FST, etc..."); try {
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
if (!SerializationOptimizer.class.isAssignableFrom(clazz)) {
throw new RpcException("The serialization optimizer " + className + " isn't an instance of " + SerializationOptimizer.class.getName());
} SerializationOptimizer optimizer = (SerializationOptimizer) clazz.newInstance(); if (optimizer.getSerializableClasses() == null) {
return;
} for (Class c : optimizer.getSerializableClasses()) {
SerializableClassRegistry.registerClass(c);
} optimizers.add(className);
} catch (ClassNotFoundException e) {
throw new RpcException("Cannot find the serialization optimizer class: " + className, e);
} catch (InstantiationException e) {
throw new RpcException("Cannot instantiate the serialization optimizer class: " + className, e);
} catch (IllegalAccessException e) {
throw new RpcException("Cannot instantiate the serialization optimizer class: " + className, e);
}
}
(3)加载指定的序列化类
调用optimizeSerialization(URL url)方法,将指定的序列化类加载到缓存,通常配置kryo, fst序列化,不配置,默认用hessian2序列化。
2、实现refer()方法,此方法实现了服务消费者指向一个远程地址的代理接口(invoker,可能是一个伪装的集群或本地调用),返回Invoker对象,用于服务调用。
实现逻辑为:
(1)加载指定的序列化类
调用optimizeSerialization(URL url)方法,将指定的序列化类加载到缓存,通常配置kryo, fst序列化,不配置,默认用hessian2序列化。
(2)创建DubboInvoker对象,加入invokers内存缓存,返回dubboInvoker对象,结束。
public <T> Invoker<T> refer(Class<T> serviceType, URL url) throws RpcException {
optimizeSerialization(url);
// create rpc invoker.
DubboInvoker<T> invoker = new DubboInvoker<T>(serviceType, url, getClients(url), invokers);
invokers.add(invoker);
return invoker;
}
(3)下面我们来分析创建DubboInvoker对象的过程。
创建时调用如下语句:new DubboInvoker<T>(serviceType, url, getClients(url), invokers)。原始构造方法定义如下:
public DubboInvoker(Class<T> serviceType, URL url, ExchangeClient[] clients, Set<Invoker<?>> invokers) {
super(serviceType, url, new String[]{Constants.INTERFACE_KEY, Constants.GROUP_KEY, Constants.TOKEN_KEY, Constants.TIMEOUT_KEY});
this.clients = clients;
// get version.
this.version = url.getParameter(Constants.VERSION_KEY, "0.0.0");
this.invokers = invokers;
}
传入四个参数:
serviceType:要调用的服务接口;
url:根据消费端声明确定的调用url;
clients:用于底层远程通讯信息交换的客户端数组;
invokers:DubboProtocol创建的所有invoker集合,此时共享给DubboInvoker对象;
clients数组由DubboProtocol.refer()中使用getClients(url)得到,我们看看实现逻辑:
private ExchangeClient[] getClients(URL url) {
// 此变量用于判断是否是共享连接
boolean service_share_connect = false;
//得到url中的connections数量,默认为0,此设置的意义为限制客户端连接数量,具体含义见下面标注
int connections = url.getParameter(Constants.CONNECTIONS_KEY, 0);
// if not configured, connection is shared, otherwise, one connection for one service
if (connections == 0) {
service_share_connect = true;
connections = 1;
} ExchangeClient[] clients = new ExchangeClient[connections];
for (int i = 0; i < clients.length; i++) {
if (service_share_connect) {
clients[i] = getSharedClient(url);
} else {
clients[i] = initClient(url);
}
}
return clients;
}
连接控制,此服务如果调用非常频繁,可以启用连接池,指定最大长连接数。
客户端连接控制:限制客户端服务使用连接不能超过 10 个
<dubbo:reference interface="com.foo.BarService" connections="10" />
或<dubbo:service interface="com.foo.BarService" connections="10" /> 服务端连接控制:限制服务器端接受的连接不能超过 10 个
<dubbo:provider protocol="dubbo" accepts="10" />
或<dubbo:protocol name="dubbo" accepts="10" />
如果是长连接,比如 Dubbo 协议,connections 表示该服务对每个提供者建立的长连接数,如果服务提供方和消费方都设置了,默认用覆盖策略,reference覆盖provider。
getSharedClient(url)是得到共享客户端的方法,代码如下:
/**
* Get shared connection
*/
private ExchangeClient getSharedClient(URL url) {
String key = url.getAddress();
ReferenceCountExchangeClient client = referenceClientMap.get(key);
if (client != null) {
if (!client.isClosed()) {
client.incrementAndGetCount();
return client;
} else {
referenceClientMap.remove(key);
}
}
synchronized (key.intern()) {
ExchangeClient exchangeClient = initClient(url);
client = new ReferenceCountExchangeClient(exchangeClient, ghostClientMap);
referenceClientMap.put(key, client);
ghostClientMap.remove(key);
return client;
}
}
initClient(url)是根据传入的url初始化连接客户端,代码如下:
/**
* Create new connection
*/
private ExchangeClient initClient(URL url) { // client type setting.默认用netty
String str = url.getParameter(Constants.CLIENT_KEY, url.getParameter(Constants.SERVER_KEY, Constants.DEFAULT_REMOTING_CLIENT)); String version = url.getParameter(Constants.DUBBO_VERSION_KEY);
boolean compatible = (version != null && version.startsWith("1.0."));
url = url.addParameter(Constants.CODEC_KEY, DubboCodec.NAME);
// enable heartbeat by default
url = url.addParameterIfAbsent(Constants.HEARTBEAT_KEY, String.valueOf(Constants.DEFAULT_HEARTBEAT)); // BIO is not allowed since it has severe performance issue.
if (str != null && str.length() > 0 && !ExtensionLoader.getExtensionLoader(Transporter.class).hasExtension(str)) {
throw new RpcException("Unsupported client type: " + str + "," +
" supported client type is " + StringUtils.join(ExtensionLoader.getExtensionLoader(Transporter.class).getSupportedExtensions(), " "));
} ExchangeClient client;
try {
// connection should be lazy,创建可延迟连接的客户端
if (url.getParameter(Constants.LAZY_CONNECT_KEY, false)) {
client = new LazyConnectExchangeClient(url, requestHandler);
} else {
client = Exchangers.connect(url, requestHandler);
}
} catch (RemotingException e) {
throw new RpcException("Fail to create remoting client for service(" + url + "): " + e.getMessage(), e);
}
return client;
}
3、 下面我们分析DubboProtocol对ExchangeHandler接口的实现逻辑,就是建立连接用到的requestHandler对象,它是对request处理的接口对象。以下代码把实现代码隐藏了。
private ExchangeHandler requestHandler = new ExchangeHandlerAdapter() {
//核心方法,对request传来的message(即Invocation)的回复,即调用相应invoker的invoke(invocation)方法,返回调用结果
public Object reply(ExchangeChannel channel, Object message) throws RemotingException {}
//接受请求,如果message是一个Invocation,则调用reply()不返回结果,否则调用父类received(),其实什么也不干
public void received(Channel channel, Object message) throws RemotingException {}
//调用onconnect设置的方法,即当连接成功时触发的方法
public void connected(Channel channel) throws RemotingException {}
//调用disconnect设置的方法,即当连接关闭时触发的方法
public void disconnected(Channel channel) throws RemotingException {}
//调用方法的实现,内部根据methodKey调用createInvocation()创建Invocation对象,调用received()方法
private void invoke(Channel channel, String methodKey) {}
//创建Invocation对象并返回,其中根据URL的属性和methedKey初始化Invocation对象
private Invocation createInvocation(Channel channel, URL url, String methodKey) {}
};
public Object reply(ExchangeChannel channel, Object message) throws RemotingException {
if (message instanceof Invocation) {
Invocation inv = (Invocation) message;
//从缓存中得到invoker对象
Invoker<?> invoker = getInvoker(channel, inv);
// 如果设置了回调服务方法,比较设置的回调方法在invoker对象中是否声明了该方法
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());
//调用invoke并返回结果
return invoker.invoke(inv);
}
throw new RemotingException(channel, "Unsupported request: " + message == null ? null : (message.getClass().getName() + ": " + message) + ", channel: consumer: " + channel.getRemoteAddress() + " --> provider: " + channel.getLocalAddress());
}
代码实现中经常看见ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(DubboProtocol.NAME)类似的语句,这是Dubbo默认的类动态加载实例化的方式SPI,替代了SpringBean管理机制,实现了IOC和AOP的功能。以后的章节会详细讨论。
最后,我们分析一下实际的方法调用实现,即DubboInvoker.doInvoke()
protected Result doInvoke(final Invocation invocation) throws Throwable {
RpcInvocation inv = (RpcInvocation) invocation;
final String methodName = RpcUtils.getMethodName(invocation);
inv.setAttachment(Constants.PATH_KEY, getUrl().getPath());
inv.setAttachment(Constants.VERSION_KEY, version); ExchangeClient currentClient;
if (clients.length == 1) {
currentClient = clients[0];
} else {
currentClient = clients[index.getAndIncrement() % clients.length];
}
try {
boolean isAsync = RpcUtils.isAsync(getUrl(), invocation);
boolean isOneway = RpcUtils.isOneway(getUrl(), invocation);
int timeout = getUrl().getMethodParameter(methodName, Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
if (isOneway) { //不需要返回值,返回空的RpcResult对象
boolean isSent = getUrl().getMethodParameter(methodName, Constants.SENT_KEY, false);
currentClient.send(inv, isSent);
RpcContext.getContext().setFuture(null);
return new RpcResult();
} else if (isAsync) { //异步调用,调用后可以用RpcContext.getFuture()异步获取返回结果
ResponseFuture future = currentClient.request(inv, timeout);
RpcContext.getContext().setFuture(new FutureAdapter<Object>(future));
return new RpcResult();
} else { //默认是同步调用,需要有返回结果,此时要清空Future
RpcContext.getContext().setFuture(null);
return (Result) currentClient.request(inv, timeout).get();
}
} catch (TimeoutException e) {
throw new RpcException(RpcException.TIMEOUT_EXCEPTION, "Invoke remote method timeout. method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e);
} catch (RemotingException e) {
throw new RpcException(RpcException.NETWORK_EXCEPTION, "Failed to invoke remote method: " + invocation.getMethodName() + ", provider: " + getUrl() + ", cause: " + e.getMessage(), e);
}
}
四、其他协议实现
1、HessianProtocol实现
以HTTP、HessianSkeleton为底层实现,实现了doExport()和doRefer()方法。
Hessian协议用于集成 Hessian 的服务,Hessian 底层采用 Http 通讯,采用 Servlet 暴露服务,Dubbo 缺省内嵌 Jetty 作为服务器实现。
Dubbo 的 Hessian 协议可以和原生 Hessian 服务互操作,即:
- 提供者用 Dubbo 的 Hessian 协议暴露服务,消费者直接用标准 Hessian 接口调用
- 或者提供方用标准 Hessian 暴露服务,消费方用 Dubbo 的 Hessian 协议调用。
特性
- 连接个数:多连接
- 连接方式:短连接
- 传输协议:HTTP
- 传输方式:同步传输
- 序列化:Hessian二进制序列化
- 适用范围:传入传出参数数据包较大,提供者比消费者个数多,提供者压力较大,可传文件。
- 适用场景:页面传输,文件传输,或与原生hessian服务互操作
约束
- 参数及返回值需实现
Serializable
接口 - 参数及返回值不能自定义实现
List
,Map
,Number
,Date
,Calendar
等接口,只能用 JDK 自带的实现,因为 hessian 会做特殊处理,自定义实现类中的属性值都会丢失。
配置
<dubbo:protocol name="hessian" port="8080" server="jetty" />
2、RmiProtocol实现
以spring的Rmi框架为底层实现,实现了doExport()和doRefer()方法。
RMI 协议采用 JDK 标准的 java.rmi.* 实现,采用阻塞式短连接和 JDK 标准序列化方式。
注意:如果正在使用 RMI 提供服务给外部访问 1,同时应用里依赖了老的 common-collections 包 2 的情况下,存在反序列化安全风险 3。
特性
连接个数:多连接
连接方式:短连接
传输协议:TCP
传输方式:同步传输
序列化:Java 标准二进制序列化
适用范围:传入传出参数数据包大小混合,消费者与提供者个数差不多,可传文件。
适用场景:常规远程服务方法调用,与原生RMI服务互操作
约束
参数及返回值需实现 Serializable 接口
dubbo 配置中的超时时间对 RMI 无效,需使用 java 启动参数设置:-Dsun.rmi.transport.tcp.responseTimeout=3000,参见下面的 RMI 配置
3、其他协议实现
还实现了http协议,webservice协议,rest协议,thrift协议等,协议说明详见dubbo用户手册
最新文章
- C语言:使用命令行参数用字符串读取流和输出流进行文本文件的复制
- 【基础知识】Sql和Ado.Net第12天
- 如何从Win7中提取制作Windows PE3.0
- leetcode 组合题
- windows 基础及基本软件测试环境搭建
- 查看linux内存、cpu
- 转载:mybatis和hibernate 解析
- thinkphp 3.2.3 入门示例2(URL传参数的几种方式)
- H3C系列之三层交换机系统版本升级
- shell编程--流程控制for,do-while,if-then,break,continue,case等
- 入门者必看!SharePoint之CAML总结(实战)
- ldap配置系列三:grafana集成ldap
- Git实操
- 改善JAVA代码01:考虑静态工厂方法代替构造器
- Python安全 - 从SSRF到命令执行惨案
- Nodejs 使用log4js日志
- eclipse中tomcat启动成功,浏览器访问失败
- C# winfrom 当前程序内存读取和控制
- Python 不可变对象练习
- linux C守护进程编写