两个 JVM 之间的通信无需 RMI?
在同一台机器上运行的两个/多个 JVM 如何在没有 RMI 的情况下进行通信?
谢谢
How can two/multiple JVMs running in a same machine communicate without RMI?.
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您担心 JVM 到 JVM 通信的安全性,防止 Wireshark 等进行窥探,您可以考虑通过 SSL 安全通道或等效通道进行 RMI 通信。
但是,如果有人能够在与您的两个 JVM 相同的计算机上运行 Wireshark,这可能不足以解决您的问题。使用 RMI 的替代方案也不会让您更安全。
首先,如果坏人有足够的权限来运行 Wireshark,他们几乎肯定有权限以破坏您对安全通道的使用的方式干扰 JVM。例如,他们可能会将调试器附加到 JVM,或者破解应用程序代码(通过文件系统)以泄露您试图保护的信息。
简而言之,您最好只使用 RMI,并花时间确保坏人无法进入您的计算机来运行 Wireshark(等)。
If you are concerned about the security of JVM to JVM communication against snooping with Wireshark, etc, you could consider doing your RMI communication over an SSL secured channel, or the equivalent.
However, if someone is able to run Wireshark on the same machine as your two JVMs, this probably not be sufficient to solve your problems. And using an alternative to RMI is not going to make you more secure either.
For a start, if the bad guys have sufficient privilege to run Wireshark, they almost certainly have the privilege to interfere with the JVMs in ways that would subvert your use of a secured channel. For example, they could probably attach a debugger to the JVMs, or hack the application code (via the file system) to leak the information you are trying to protect.
In short, you would be better off just using RMI, and spending your time making sure that the bad guys cannot get into your machine to run Wireshark (etc) in the first place.
通信或调用方法?
您始终可以打开套接字并通过任意协议直接通信,甚至以序列化形式来回传递对象。在大多数操作系统上,同一台机器上的进程之间的套接字连接比机器之间的连接更快、更高效。
一个好的起点是查看 JMS 教程。 JMS 需要额外的代理进程,但使 JVM 之间的通信变得轻而易举。
还有像 J2EE 甚至基于 http 的 XML-RPC 之类的东西,但这些可能超出了您的需求。
Communicate or invoke methods?
You could always open sockets and communicate directly via an arbitrary protocol, or even pass objects back and forth in serialized forms. On most operating systems, socket connections between processes on the same machine are faster and more efficient than connections between machines.
A good place to start would be to look at a JMS tutrial. JMS requires an extra broker process, but makes communication between JVMs a piece of cake.
There are also things like J2EE and even http based XML-RPC but these might be overkill for your needs.
套接字、远程 EJB、Web 服务……来自我的脑海。您的具体情况是什么?
sockets, remote EJB, web services ... from the top of my head. What is your specific case?