我目前正在进行一个涉及广泛使用 Java RMI 的项目,我想知道是否有人知道有关它的任何好的资源。
我目前找到的材料所遇到的问题是它通常已经过时(如 Java 1.3)和/或半完整。 我什至很乐意买一本关于它的书,但在亚马逊上看,所有的书都已经有7年了。
因此,如果有人知道任何好的资源、书籍或好的示例实现,我将非常有兴趣了解它们。
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 interested to hear about them.
发布评论
评论(10)
RMI Hello World 看起来不错作为一个开始。 当然,这仍然是一个简单的示例,因此有关 RMI 性能/可扩展性的提示可能会很有用因为您已经熟悉 RMI 了。
RMI Hello World looks nice for a start. Of course it's still a simple example, so maybe tips on RMI performance/scalability will be useful since you're already familiar with RMI.
Java.RMI 多年来变化很小,因此大多数旧文档仍然可以参考。 请注意,一个重要的变化是,如果您使用的是 Java 5.0 版本,则需要编译 RMI 存根。
大多数人已经放弃了 RMI,并接受了分布式系统的 River(以前称为 Jini)。
如果您仍在考虑继续使用 RMI,那么我建议您阅读 Oracle 文档 或在他们的论坛上发布您的问题。
至于书籍……William Grosso 着的Java RMI 或Elliotte Harold 着的Java 网络编程。
The Java.RMI has changed very little over the years, so most of the old documentation can still be referenced. Note that one significant change is the need to compile the RMI stubs if you are using a version of Java 5.0.
Most people have moved away from RMI and have embraced River (previously called Jini) for distributed systems.
If you are still thinking of moving forward with RMI then I would suggest reading the Oracle documentation or posting your questions on their forums.
As for books… Java RMI by William Grosso or Java Network Programming by Elliotte Harold.
RMI 并没有改变那么多。 我觉得1.3时代的书就可以了。
RMI hasn't changed that much. I think 1.3 era books will be just fine.
谢谢大家的回答,我认为人们所说的 RMI 没有太大改变是正确的,但是教程仍然可以更好一点,他们掩盖了一些重要的观点。
最后,我发现迄今为止最好的一本书,涵盖了 RMI 的一些真正好的部分,例如激活,是 Java 网络编程和分布式计算。
我确实查看了其他 O'reilly Java RMI 本书,在我看来,对于任何比最小的 RMI 项目更大的项目来说,它根本不是很好。
Thank you all for your answers I think what people said about RMI not having changed much is correct, however the tutorials could still be a bit better they gloss over some important points.
In the end the best book by far that I found, that covers some of the really good bits of RMI such as Activation was Java Network Programming and Distributed Computing.
I did look at the other O'reilly Java RMI book and in my opnion its not very good at all, for anything bigger than the smallest of RMI projects.
如果您要大量使用 RMI,我建议您查看 Spring 远程处理。 它对抽象远程协议有很大帮助,可以帮助您在以后需要时切换远程实现(例如切换到 Hessian 或 SOAP)。
如果您使用 RMI 或任何其他远程对象协议,需要记住的一件事是,您可以通过调用远程对象上的方法来生成大量流量。 在您的代码中,这些对象是远程的可能并不明显。 它可能会产生性能问题。
如果可以的话,我建议您采用或多或少面向服务的架构,在其中调用远程服务来获取数据对象,但不要对这些对象有太多行为......
If you are going to make heavy use of RMI, I would suggest having a look at Spring Remoting. It helps a lot in abstracting the remoting protocol, help you switch remoting implementation later if you need to (for example switch to Hessian, or SOAP).
One thing to keep in mind if you use RMI or any other remote object protocol, is that you can generate a lot of traffic by calling methods on remote objects. It might not be obvious in your code that those objects are remote. It might generate performances problems.
If you can, I would advise you to have a architecture more or less service oriented, where you call remote services to get data object, but not to have too much behaviour on those objects ...
您是否尝试过 Sun RMI 教程? Sun 的教程都非常好,它们通常是我学习 Java 的第一个地方。
我们在学校使用的一本书有很好的示例代码:J2EE 开发人员手册 。 请记住,这是一本大约 1500 页的巨大参考书,其中只有一章(大约 50 页)是关于 RMI 的。
Have you tried Sun't RMI tutorial? The Sun tutorials are all very good, and they're usually the first place I start for learning anything about Java.
A book that we used in school that has good example code is J2EE Developer's Handbook. Bear in mind that this is a huge reference book of about 1500 pages with only one chapter (about 50 pages) on RMI.
O'Reilly 的 RMI 书相当不错。 大胆试试吧。
The O'Reilly RMI book is pretty good. Go for it.
关于多宿主的绝对无价的文章 RMI(具有多个 IP 的主机)以非常容易理解的方式解释 RMI,并探讨在具有多个 IP 地址的计算机上托管注册表以及如何处理私有 IP 的问题。 救了我的培根。
这是来自 回溯存档。
Absolutely invaluable article on multi homed RMI (hosts with multiple IPs) Explains RMI in a very easy to understand way and goes into the issues of hosting registries on machines with more than a single IP address and how private IPs can be dealt with too. Saved my bacon.
Here is the article with Images from the way back archive.
这是使用 Redisson 框架进行远程方法调用的另一个很好的示例:
假设
YourServiceImpl
包含您需要远程调用的方法并实现YourService
接口。YourServiceImpl应该通过RemoteService对象在Redisson中注册:
要远程调用方法,只需要服务接口:
它还支持异步调用。
更多详细信息此处
Here is another good example of remote method invocation with Redisson framework:
Let's assume
YourServiceImpl
contains method you need to invoke remotely and implementsYourService
interface.YourServiceImpl should be registered in Redisson via RemoteService object:
To invoke method remotely only service interface is needed:
Also it supports asynchronous calls.
More details here
除了已经提到的内容之外,文章了解 Java RMI 内部结构恕我直言,这是相当不错的,稍微了解了一下内部结构。
In addition to the ones already mentioned, the article Understanding Java RMI Internals was quite decent IMHO, going a little bit through the internals.