tags:

views:

786

answers:

3

For a typical Web client -to- Servlet/WS -to- Business Tier (Spring or EJB) app, what are the trade-offs of approaches like remote RPC or messaging for Web (Servlet) tier to remote Business tier, aside from the basic sync/async aspects?

A: 

We use RMI via Spring and find it very easy to use, fairly robust and fast. Although our requirements were for a fairly responsive link and there was no real need to add a messaging component.

Chris Kimpton
+2  A: 

By web client do you mean web browser? If so looking at stuff like DWR or JAX-RS are my recommendations. RMI or JMS only really work when both sides are Java code.

With any remoting technology the biggest issue using them tends to be how intrusive the technology becomes on your business objects. e.g. using RMI interface/exceptions everywhere or using the JMS APIs inside your business code.

My recommendation is to use POJOs everywhere in Java then use a technology like Spring Remoting to layer on your middleware whether its RMI or JMS or whatever - but totally de-couple the middleware code from your business logic so you can switch between technologies at any time (and keep your business logic code simpler and focussed on your business problem).

For example see the Camel implementation of Spring Remoting which then allows you to use any of these transports and protocols such as RMI, JMS or even plain HTTP, email, files or XMPP - then switch between them trivially using a simple URI string change.

James Strachan
A: 

SUN RMI broke for us.

The settings and garbage collection for a very long running application with continuous meassaging. We are patching to make it work continuously. JMS applications we run don't get the out of memory errors or gc problems that RMI does. Anything that needs to call System.gc() periodically and doesn't work with incremental collection to recover resources is coded wrong.

RMI reliability improves with the JDK 6 and the correct property settings, but JHC, it's a bodgey framework. RMI would be vastly improved by using channels in nio and fixing the sun nio uses of system.gc().

The correct answer - seperate communication (mechanism) from the domain code. RPC is tightly coupled, and the protocol and application can interfere with each other. JMS seperates the protocol from the application, a much better paradigm.

Joe