Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What remoting approach for Java application would you recommend?

Tags:

java

remoting

I wonder how is the best way to integrate Java modules developed as separate J(2)EE applications. Each of those modules exposes Java interfaces. The POJO entities (Hibernate) are being used along with those Java interfaces, there is no DTO objects. What would be the best way to integrate those modules i.e. one module calling the other module interface remotely?

I was thinking about: EJB3, Hessian, SOAP, JMS. there are pros and cons of each of the approaches.

Folks, what is your opinion or your experiences?

like image 988
Tomasz Błachowicz Avatar asked Jul 03 '09 10:07

Tomasz Błachowicz


People also ask

What is Spring remoting in Java?

The Spring approach to HTTP Remoting allows clients to communicate with the Spring-hosted server code via HTTP without the client code requiring any knowledge of HTTP being used. Instead, the client Java code only "sees" normal business-related Java objects (usually interfaces) rather than HTTP-specific objects.

Is Java RMI still used?

RMI and CORBA(Common Object Request Broker Architecture) attempt to solve a problem that people thought was important in the early 1990s. However, today we can't consider RMI as modern technology and nowadays we have REST, SOAP as the de-facto standards for communicating with remote services.

Why use Java RMI?

The primary advantages of RMI are: Object Oriented: RMI can pass full objects as arguments and return values, not just predefined data types. This means that you can pass complex types, such as a standard Java hashtable object, as a single argument.

What is basic remoting?

Overview. Remoting is a fancy word describing technologies that allow code in one process invokes a service (calls a remote procedure, or invokes a method on a remote object) in another process. There are several flavors of remoting: Non-object oriented vs. object-oriented.


2 Answers

Having dabbled with a few of the remoting technologies and found them universally unfun I would now use Spring remoting as an abstraction from the implementation. It allows you to concentrate on writing your functionality and let Spring handle the remote part with some config. you have the choice of several implementations (RMI, Spring's HTTP invoker, Hessian, Burlap and JMS). The abstraction means you can pick one implementation and simply swap it if your needs change. See the SpringSource docs for more information.

like image 95
Rich Seller Avatar answered Nov 10 '22 11:11

Rich Seller


The standard approach would be to use plain RMI between the various service components but this brings issues of sharing your Java interfaces and versioning changes to your domain model especially if you have lots of components using the same classes.

Are you really running each service in a separate VM? If these EJBs are always talking to each other then you're best off putting them into the same VM and avoiding any remote procedure calls as these services can use their LocalInterfaces.

The other thing that may bite you is using Hibernate POJOs. You may think that these are simple POJOs but behind the scenes Hibernate has been busy with CGLib trying to do things like allow lazy initialization. If these beans are serialzed and passed over remote boundaries then you may end up with odd Hibernate Exception getting thown. Personally I'd prefer to create simple DTOs or write the POJOs out as XML to pass between components. My colleagues would go one step further and write custom wire protocols for transferring the data for performance reasons.

Recently I have been using the MULE ESB to integrate various service components. It's quite nice as you can have a mix of RMI, sockets, web services etc without having to write most of the boiler plate code.

http://www.mulesource.org/display/COMMUNITY/Home

like image 27
pjp Avatar answered Nov 10 '22 11:11

pjp