Get the JMS Message
The Java Message Service provides a more
reliable way to send messages than the
RPC/RMI model
by Kevin Jones
Developers are accustomed to calling synchronous methods; it's the normal mechanism we use to dispatch messages to objects. Java developers are also accustomed to using remote procedure call (RPC) in the guise of remote method invocation (RMI). RPC is also typically synchronous. However, synchronous RPC simply won't do the job in some cases (for example, when a client, such as a traveling salesman, is disconnected from the server). Also, RPC is unreliable; it has many unusual failure modes. If you need reliable communication, then RPC may not be good enough.
Messaging can fix some of these RPC problems. Let's examine the Java Message Service (JMS), a Java API for messaging that allows Java clients and servers to work with any JMS-compatible provider.
Problems with RPC and RMI
When you use RPC, typically you are making a call out of your process and often from your machine to another machine across the network. The machine you are calling may be close, or it may be far away. In either case, the call results in extra cost caused by several sources.
To make an RPC call, the parameters to the call must be marshalled onto the network and demarshalled at the receiver. The same is true for the response. This adds major overhead.
The distance between the sender and the receiver affects the amount of time the call takes. Each network router and switch between the two introduces an overhead into the call. Each device has a fundamental minimum time it takes them to respond to data. This time limit is the latency of the device. This latency is often on the order of 10-4 seconds (the device requires at least this amount of time to handle each packet). For large packets, this is not a major overhead; the time to handle the data often swamps the latency. Much network traffic, however, consists of small control packets. Often the latency time is much larger than the actual packet throughput time, and adds significant overhead.
Back to top
|