Java RMI Resources

后端 未结 10 1742
一生所求
一生所求 2021-02-07 23:40

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 havi

相关标签:
10条回答
  • 2021-02-08 00:13

    In addition to the ones already mentioned, the article Understanding Java RMI Internals was quite decent IMHO, going a little bit through the internals.

    0 讨论(0)
  • 2021-02-08 00:15

    Here is another good example of remote method invocation with Redisson framework:

    Let's assume YourServiceImpl contains method you need to invoke remotely and implements YourService interface.

    YourServiceImpl should be registered in Redisson via RemoteService object:

    YourService yourService = new YourServiceImpl();
    
    RRemoteService remoteService = redisson.getRemoteService();
    remoteService.register(YourService.class, yourService);
    

    To invoke method remotely only service interface is needed:

    RRemoteService remoteService = redisson.getRemoteService();
    YourService service = remoteService.get(YourService.class);
    
    MyObject result = service.myMethod(someParam1, someParam2);
    

    Also it supports asynchronous calls.

    // async interface for YourService
    @RRemoteAsync(YourService.class)
    public interface YourServiceAsync {
    
        RFuture<Long> someMethod1(Long param1, String param2);
    
        RFuture<Void> someMethod2(MyObject param);
    
    }
    
    RRemoteService remoteService = redisson.getRemoteService();
    YourServiceAsync asyncService = remoteService.get(YourServiceAsync.class);
    
    RFuture<Long> res = asyncService.someMethod1(12L, "param");
    res.thenApply(r -> {
     ...
    });
    

    More details here

    0 讨论(0)
  • 2021-02-08 00:20

    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 ...

    0 讨论(0)
  • 2021-02-08 00:24

    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.

    0 讨论(0)
  • 2021-02-08 00:24

    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.

    0 讨论(0)
  • 2021-02-08 00:27

    The O'Reilly RMI book is pretty good. Go for it.

    0 讨论(0)
提交回复
热议问题