160 likes | 251 Views
Distributed Java Communications. Eric Lind CS522 Semester Project December 9, 2002. How does one distribute using Java?. Many different methods are available Sockets RMI CORBA XML (SOAP or JAX). How do I decide which to use?. Each new trend claims to be faster/stronger/better
E N D
Distributed Java Communications Eric Lind CS522 Semester Project December 9, 2002
How does one distribute using Java? • Many different methods are available • Sockets • RMI • CORBA • XML (SOAP or JAX)
How do I decide which to use? • Each new trend claims to be faster/stronger/better • Can be hard to compare different methods • Numbers are hard to come by • Which numbers to use?
Project Benchmarks • Use a simple chat application • Contrived, yes, but still demonstrates features of each method • Measure data written and read by each client or server • Not concerned with low-level traffic, but with the application level data.
Sockets Server Client Connection Request Port Bi-Directional Connection Port Port
Advantages: Nearly universal Uses the smallest amount of data to communicate Bi-directional Disadvantages: Pretty low-level Must do many things by hand No additional services provided Sockets
RMI Registry Obtain Remote Reference Obtain Remote Reference RMIChat receive(Message) RMIChat Port Port receive(Message) Each RMIChat object must implement both the client and server interface
Advantages: Standard Java API Allows remote objects to be treated as if local Includes some services Disadvantages: Uses client-pull (clients must also be servers for 2-way comm.) Setup code is cumbersome Marshalling is slow RMI
CORBA IIOP ORB ORB CORBAChat CORBAChat As with RMI, each CORBAChat object must act as both client and server
Advantages: Open standard Many platforms / languages Provides additional services Generally faster than RMI Disadvantages: Not “Java-friendly” Uses client-pull Tends to be trickier than other methods Had considerable trouble with generated classes CORBA
Chat Service Ties Runtime Runtime Runtime Stubs Stubs JAXChat JAXChat JAX-RPC Tomcat (or any Servlet-enabled Web Server) SOAP Message SOAP Message HTTP HTTP
Advantages: Uses SOAP (can talk to non-Java platforms) Very easy to develop Uses HTTP (eases security concerns) Disadvantages: Uses SOAP (XML is very verbose) Requires web server Restricts data that can be sent Still buggy JAX-RPC
Conclusions • Sockets have the lowest overhead • RMI does not add much (only 43 extra bytes) • XML adds a lot of overhead (19 times) • Must convert binary data to text • SOAP envelope is huge
Conclusions (cont.) • RMI is probably the best for pure-Java applications • Low overhead • Normal Java semantics • RMI over IIOP should put RMI on par with CORBA for speed.
Conclusions (cont.) • Web Services are (supposedly) platform neutral • Good model for general data access, not so good for bandwidth constrained applications • CORBA is still the only viable, cross-platform communications protocol, but it’s not easy to use