Search code examples
javarmi

Advantages of using Java's RMI


I'm trying to use Java RMI for remotely polling a queue. Is RMI a good method to do this? Overall, what are the advantages of using RMI over regular socket programming? Is it more efficient in terms of network bandwidth usage?


Solution

  • Is RMI a good method to do this?

    It could be. RMI is pretty simple and supported by many frameworks.

    Overall, what are the advantages of using RMI over regular socket programming?

    Simplicity for a variety of uses.

    Is it more efficient in terms of network bandwidth usage?

    RMI is built on top of regular socket programming so it can't be any more efficient. However in term of network bandwidth it is as much as 2-5x worse than what you can achieve with custom code, except of course you need to use custom coding. You are sending large byte[] or String it won't make much difference.

    Note: This is not a good reason to not use RMI. Using a faster alternative is unlikely to be justified unless you know this will be a problem and generally it isn't.

    Note: if you use RPC using another serialization, it is most likely to be more efficient. i.e. almost all alternatives are more efficient.