What is the difference between Java RMI and RPC?

149,657

Solution 1

RPC is C based, and as such it has structured programming semantics, on the other side, RMI is a Java based technology and it's object oriented.

With RPC you can just call remote functions exported into a server, in RMI you can have references to remote objects and invoke their methods, and also pass and return more remote object references that can be distributed among many JVM instances, so it's much more powerful.

RMI stands out when the need to develop something more complex than a pure client-server architecture arises. It's very easy to spread out objects over a network enabling all the clients to communicate without having to stablish individual connections explicitly.

Solution 2

The main difference between RPC and RMI is that RMI involves objects. Instead of calling procedures remotely by use of a proxy function, we instead use a proxy object.

There is greater transparency with RMI, namely due the exploitation of objects, references, inheritance, polymorphism, and exceptions as the technology is integrated into the language.

RMI is also more advanced than RPC, allowing for dynamic invocation, where interfaces can change at runtime, and object adaption, which provides an additional layer of abstraction.

Solution 3

1. Approach:

RMI uses an object-oriented paradigm where the user needs to know the object and the method of the object he needs to invoke.

RPC doesn't deal with objects. Rather, it calls specific subroutines that are already established.

2. Working:

With RPC, you get a procedure call that looks pretty much like a local call. RPC handles the complexities involved with passing the call from local to the remote computer.

RMI does the very same thing, but RMI passes a reference to the object and the method that is being called.

RMI = RPC + Object-orientation

3. Better one:

RMI is a better approach compared to RPC, especially with larger programs as it provides a cleaner code that is easier to identify if something goes wrong.

4. System Examples:

RPC Systems: SUN RPC, DCE RPC

RMI Systems: Java RMI, CORBA, Microsoft DCOM/COM+, SOAP(Simple Object Access Protocol)

Solution 4

Remote Procedure Call (RPC) is a inter process communication which allows calling a function in another process residing in local or remote machine.

Remote method invocation (RMI) is an API, which implements RPC in java with support of object oriented paradigms.

  1. You can think of invoking RPC is like calling a C procedure. RPC supports primitive data types where as RMI support method parameters/return types as java objects.

  2. RMI is easy to program unlike RPC. You can think your business logic in terms of objects instead of a sequence of primitive data types.

  3. RPC is language neutral unlike RMI, which is limited to java

  4. RMI is little bit slower to RPC

Have a look at this article for RPC implementation in C

Solution 5

RMI or Remote Method Invokation is very similar to RPC or Remote Procedure call in that the client both send proxy objects (or stubs) to the server however the subtle difference is that client side RPC invokes FUNCTIONS through the proxy function and RMI invokes METHODS through the proxy function. RMI is considered slightly superior as it is an object-oriented version of RPC.

From here.

For more information and examples, have a look here.

Share:
149,657

Related videos on Youtube

Aran
Author by

Aran

Updated on October 23, 2020

Comments

  • Aran
    Aran over 3 years

    What is the actual difference between Java RMI and RPC?

    I have read in some places that RMI uses Objects?

    • Yousha Aleayoub
      Yousha Aleayoub over 4 years
      I think RMI in Java is something like gRPC in .Net...
  • starcorn
    starcorn over 13 years
    method is what functions is called in java, function is what method is called in c/c++. So still what's the difference?
  • Ellen Spertus
    Ellen Spertus over 12 years
    A difference is that (in the case of instance methods), there is an invoking object. The invoking object either needs to be sent (along with its code) or needs to live on the remove server but have a way to be referenced on the local server.
  • mins
    mins almost 10 years
    What are the differences you implicitly emphasize, but don't clarify, between a method and a function? In Java there is no functions... but in OOP as far as I can remember, they are synonyms, and so are invocation and call.
  • Dan
    Dan about 9 years
    Ignoring how specific programming languages treat methods vs. functions, the literary meaning is that functions return a value whereas methods modify state.
  • MattC
    MattC about 9 years
    This is incorrect. RPC is Java based as well. JAX-RPC 1.1 was replaced by 2.0, which was then renamed JAX-WS. In Java, when you talk about RPC, you are talking about SOAP and Web Services. Here is an IBM article about JAX-RPC 1.1 changing to JAX-WS. ibm.com/developerworks/library/ws-tip-jaxwsrpc
  • Noor Nawaz
    Noor Nawaz almost 9 years
    RPC invokes FUNCTIONS through the proxy function and RMI invokes METHODS using the proxy OBJECT. Right?
  • xji
    xji about 8 years
    @MattC I think the article you linked to pointed out that the reason for this name change from "JAX-RPC" to "JAX-WS" is exactly that the original name was not accurate, as this specification involved more than just "RPC" in a traditional sense. So this answer, which talks about what RPC traditionally means, is still correct.
  • fortran
    fortran about 8 years
    yeah, what I meant is that RPC originated in the C/Unix world (at least the most common RPC implementation, ONCRPC) and as such it is modeled after that computation model; of course nothing prevents to implement it on top of any other programming language
  • Navin Israni
    Navin Israni about 7 years
    A little difference of opinion on the way semantics are used don't make an answer wrong (or misleading). Anyone who reads this can easily understand that "C based" basically means "procedure oriented" - Anyone who has learnt Java knows the POP vs OOP difference.
  • Gunjan Shah
    Gunjan Shah almost 6 years
    In my application, I am using JAX-WS to expose/consume soap services. Can I call it RPC type mechanism ? As per my understanding, in JAX-WS, we are invoking remote method using java reflection API. So its matching with definition of RPC. Please confirm !
  • foo
    foo about 5 years
    Which protocol is "RPC", specifically? To my knowledge, there's two dozen protocols for RPC, and half of those available for Java.
  • foo
    foo about 5 years
    RPC invokes a procedure/function - flat out.
  • Hitesh Bajaj
    Hitesh Bajaj over 4 years
    can a nodejs client(say) invoke RMI calls on server? Is there any such way?
  • fortran
    fortran over 4 years
    @HiteshBajaj you could use CORBA for that as RMI supports CORBA interoperability, I'm almost sure there are bindings for all imaginable languages; if you need a more elaborate answer you should ask a proper question instead of a comment.
  • user207421
    user207421 over 4 years
    The client doesn't normally 'send proxy objects (or stubs) to the server'. Poor quality citation.
  • user207421
    user207421 over 4 years
    @foo No doubt he is referring to Sun-RPC, but all RPCs mean Remote Procedure Call, nO objects or methods, so it isn't really relevant.
  • user207421
    user207421 over 3 years
    @xji JAX-RPC is Java-based. The original Sun RPC was C-based, but the idea can be implemented in many languages, including Java.