rmi

spring远程调用

允我心安 提交于 2019-12-03 19:34:02
Spring 远程调用 远程调用是客户端应用和服务端之间的会话。在客户端上所需要的一些功能并不包括在该应用的职能范围内。所以应用向能提供这些功能的其他系统寻求帮助。远程的应用通过远程服务把这些功能公开出来。 一、Spring远程调用概览 Spring为各种远程访问技术的集成提供了工具类。Spring远程支持是由普通(Spring)POJO实现的,这使得开发具有远程访问功能的服务变得相当容易。 Spring远程调用支持6种不同的RPC模式:远程方法调用(RMI)、Caucho的Hessian和Burlap、Spring自己的HTTP invoker、EJB和使用JAX-RPC 的Web Services。 RPC模式 在何种情况下有用 远程方法调用(RMI) 不考虑网络限制(如防火墙)时,访问/公开基于Java的服务 Hessian或 Burlap 考虑网络限制时,通过HTTP访问/公开基于Java的服务 HTTP invoker 考虑网络限制时,访问/公开基于Spring的服务 EJB 访问用EJB实现的遗留的J2EE系统 JAX-RPC 访问Web Services 其中(来自Spring2.0参考手册): l 远程方法调用(RMI)。通过使用 RmiProxyFactoryBean和 RmiServiceExporter,Spring同时支持传统的RMI(使用java.rmi

java rmi -Djava.rmi.server.hostname=localhost still opens a socket listening on 0.0.0.0

半世苍凉 提交于 2019-12-03 19:30:49
问题 I use the -Djava.rmi.server.hostname=localhost option to make rmi listen on localhost only, but netstat shows the socket is listening on 0.0.0.0 . The strange thing is that the RMI RenewClean thread shows its using localhost. E.g. RMI RenewClean-[localhost:59357] I assumed that if I set -Djava.rmi.server.hostname=localhost it should only be listening on 127.0.0.1 Am I misunderstanding what java.rmi.server.hostname controls? 回答1: I assumed that if I set -Djava.rmi.server.hostname=localhost it

使用 RMI + ZooKeeper 实现远程调用框架

旧时模样 提交于 2019-12-03 19:20:32
在 Java 世界里,有一种技术可以实现“跨虚拟机”的调用,它就是 RMI (Remote Method Invocation,远程方法调用)。例如,服务A 在 JVM1 中运行,服务B 在 JVM2 中运行,服务A 与 服务B 可相互进行远程调用,就像调用本地方法一样,这就是 RMI。在分布式系统中,我们使用 RMI 技术可轻松将 服务提供者 (Service Provider)与 服务消费者 (Service Consumer)进行分离,充分体现组件之间的弱耦合,系统架构更易于扩展。 本文先从通过一个最简单的 RMI 服务与调用示例,让读者快速掌握 RMI 的使用方法,然后指出 RMI 的局限性,最后笔者对此问题提供了一种简单的解决方案,即使用 ZooKeeper 轻松解决 RMI 调用过程中所涉及的问题。 下面我们就从一个最简单的 RMI 示例开始吧! 1 发布 RMI 服务 发布一个 RMI 服务,我们只需做三件事情: 定义一个 RMI 接口 编写 RMI 接口的实现类 通过 JNDI 发布 RMI 服务 1.1 定义一个 RMI 接口 RMI 接口实际上还是一个普通的 Java 接口,只是 RMI 接口必须继承 java.rmi.Remote ,此外,每个 RMI 接口的方法必须声明抛出一个 java.rmi.RemoteException 异常,就像下面这样: <!--

In Java RMI, how can a client know that its server is dead?

耗尽温柔 提交于 2019-12-03 18:11:26
问题 Currently, I'm working on a chat server-client program which is built on Java RMI. In order for a client to detect that its connected server has been died, I can only think of two possible solutions, but neither of them works well in my case. 1. Wait until the client needs to invoke some methods of the server, this way does not work well because if the chat client does not invoke any method of server, it will not know that server is dead, thus the chat client can not receive any new chat

How Fast Might RMI Be?

强颜欢笑 提交于 2019-12-03 17:15:47
I have seen the question: Communication between two separate Java desktop applications (answer: JGroups) and I'm thinking about implementing something with JavaGroups or straight RMI but speed is of the essence. I'm not sending large amounts of data around (content of MIDI Messages, so 3 bytes each, no more than say two messages every three milliseconds) and this will be all on the same machine. Is it daft to think that RMI/JGroups on the same physical machine will be slow? (My thought is that I can't afford more than 1ms of latency, since I've already got some, but I'm not sure how to best

rmi.transport.tcp.tcptransport Connectionhandler consumes much CPU

a 夏天 提交于 2019-12-03 16:49:21
i am running an third party RMI-Server app providing exactly one method ("getImage()" returns an image as byte[]). The implementation of this method (getting the image via a SOAP-WS) is provide by me. The problem on running this RMI-Server is the high CPU consumption (measured with jvisualvm): 65% of cpu time go into "sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run()" and on second place with 15% is "sun.net.www.http.KeepAliveCache.run()" . The "real" work (scaling the image) comes on 4th place. The server is running on win 2003 server. i guess there is something wrong with resource

Java RMI Resources

送分小仙女□ 提交于 2019-12-03 16:44:51
问题 I am currently undertaking a project that involves extensive use of Java RMI and I was wondering if anyone is aware of any good resources about it. The problem I am having with the material I am finding currently is that its usually quite out of date (like Java 1.3) and / or half complete. I would even be happy to buy a book on it but looking on Amazon all the books are like 7 years old. So if anyone is aware of any good resources, books or good example implementations I would be very

RMI vs REST Service

孤街醉人 提交于 2019-12-03 16:27:30
问题 We are developing a service for our portal / web client developed using JSF . My advice was to expose the service as REST but another team member said to go with RMI implementation since its easier to deal in java object from development and testing point of view. My argument was development and testing efforts with be pretty much the same but we will get all the goodness of REST web services. FYI : We already have REST setup so there is no extra cost in framework support. This services are

Python中实现远程调用(RPC、RMI)简单例子

╄→尐↘猪︶ㄣ 提交于 2019-12-03 16:21:18
说白了,远程调用就是将对象名、函数名、参数等传递给远程服务器,服务器将处理结果返回给客户端 远程调用使得调用远程服务器的对象、方法的方式就和调用本地对象、方法的方式差不多,因为我们通过网络编程把这些都隐藏起来了。远程调用是分布式系统的基础。 远程调用一般分为两种,远程过程调用(RPC)和远程方法调用(RMI)。 RPC RPC属于函数级别的远程调用,其多是通过HTTP传输数据,数据形式有XML、JSON、序列化数据等。在此,用python做一个xml-rpc的示例。 先给服务器端server.py: from SimpleXMLRPCServer import SimpleXMLRPCServer def add(x, y): return x + y if __name__ == '__main__': s = SimpleXMLRPCServer(('127.0.0.1', 8080)) s.register_function(add) s.serve_forever() s是一个绑定了本地8080端口的服务器对象,register_function()方法将函数add注册到s中。serve_forever()启动服务器。 再给个客户端client.py: from xmlrpclib import ServerProxy if __name__ == '__main__':

Rmote学习笔记-zyh

半城伤御伤魂 提交于 2019-12-03 16:21:00
RMI的概念: RMI(Remote Method Invocation)远程方法调用是一种计算机之间利用远程对象互相调用实现双方通讯的一种通讯机制。使用这种机制,某一台计算机上的对象可以调用另外一台计算机上的对象来获取远程数据。RMI是Enterprise JavaBeans的支柱,是建立分布式Java应用程序的方便途径。在过去,TCP/IP套接字通讯是远程通讯的主要手段,但此开发方式没有使用面向对象的方式实现开发,在开发一个如此的通讯机制时往往令程序员感觉到乏味,对此RPC(Remote Procedure Call)应运而生,它使程序员更容易地调用远程程序,但在面对复杂的信息传讯时,RPC依然未能很好的支持,而且RPC未能做到面向对象调用的开发模式。针对RPC服务遗留的问题,RMI出现在世人面前,它被设计成一种面向对象的通讯方式,允许程序员使用远程对象来实现通信,并且支持多线程的服务,这是一次远程通讯的革命,为远程通信开辟新的里程碑。 RMI的理解: 在Java中,只要一个类extends了java.rmi.Remote接口,即可成为存在于服务器端的远程对象,供客户端访问并提供一定的服务。 JavaDoc描述:Remote 接口用于标识其方法可以从非本地虚拟机上调用的接口。任何远程对象都必须直接或间接实现此接口。只有在“远程接口”(扩展 java.rmi.Remote 的接口