Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the pros and cons of Web Services and RMI in a Java-only environment?

When developing distributed applications, all written in Java by the same company, would you choose Web Services or RMI? What are the pros and cons in terms of performance, loose coupling, ease of use, ...? Would anyone choose WS? Can you build a service-oriented architecture with RMI?

like image 445
cretzel Avatar asked Sep 23 '08 12:09

cretzel


People also ask

What is the purpose of Java RMI?

The Java Remote Method Invocation (RMI) system allows an object running in one Java virtual machine to invoke methods on an object running in another Java virtual machine. RMI provides for remote communication between programs written in the Java programming language.

Is Java RMI still used?

RMI is still useful, but its application is limited and generally best used in-house. One place RMI found a home was in RMI-IIOP, which became the basis of the RMI mechanism of Enterprise JavaBeans Remote Interface. However, remote EJBs are likewise not very common anymore.

What is RMI in web services?

RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing in one system (JVM) to access/invoke an object running on another JVM. RMI is used to build distributed applications; it provides remote communication between Java programs.


2 Answers

I'd try to think about it this way:

Are you going for independent services running beneath each other, and those services may be accessed by non-java applications some time in the future? Then go for web services.

Do you just want to spread parts of an application (mind the singular) over several servers? Then go for RMI and you won't have to leave the Java universe to get everything working together tightly coupled.

like image 159
Thorsten79 Avatar answered Sep 23 '22 20:09

Thorsten79


I would choose WS.

  • It is unlikely that WS/RMI will be your bottleneck.
  • Why to close the door for other possible technologies in the future?
  • RMI might have problem if version of classes on client/server get out of sync.

And... I would most likely choose REST services.

like image 45
Vilmantas Baranauskas Avatar answered Sep 23 '22 20:09

Vilmantas Baranauskas