Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Current best practice for distributed programs in Java

I am interested to implement some processes that span over machines i.e. form a distributed program. It is the functionality that these processes provide that I want to distribute and not data.
So what is currently the norm for distributed programming in Java?
Is it still RMI? Or some kind of messaging system?
I originally thought RMI and a little JMX for remote management but would like to know what is the current best practice. Seems like RMI is always "burried" under another layer (e.g. EJBs right?)

Update:
After answers and comment it seems that the current trend is to go for messaging systems? Doesn't this introduce a "centralized" component in a distributed design?

like image 607
Cratylus Avatar asked Jan 12 '13 20:01

Cratylus


3 Answers

I do not think RMI is the way to go anymore, if RMI is suitable for your task just do it with EJB as you will get many features from the application server such as security/access control, transaction management, database management, etc. implementing those in RMI is painful and waste of time.

Another option for distributed programming is to use GridGain, a powerful framework you can use to easily run your program on a cluster of commodity machines. similarly you might consider Apache Hadoop

I would start with GridGain because it is very easy to install, just unzip and run, and it is also relatively simple to integrate with your application.

Edit

RMI and Messaging system are bit different because the use of synchronous vs. asynchronous communication should depend on the overall system architecture and how different component interact with each other. For example, asynchronous communication might be more suitable when a service invocation takes long time to finish e.g. do batch operation or archive large data. In this case, the service client does not hold system resources (e.g. sockets and threads)

On the other hand, synchronous communication might be more appropriate when the service/function take short time to finish and each remote service depends on the result of the previous one.

like image 84
iTech Avatar answered Oct 17 '22 04:10

iTech


I recently used the Cajo project to do remoting among several instances of java desktop (Swing) apps. The project hasn't seen an update in a while, but it's been really easy to use, and just works, with a minimum of fuss.

It's a thin wrapper around RMI, so it's very lightweight, and very fast.

For some examples, see the article "Cajo, the easiest way to accomplish distributed programming in Java"

like image 23
GreyBeardedGeek Avatar answered Oct 17 '22 03:10

GreyBeardedGeek


Best practice is typically EJB, given you run inside an app server/Java EE stack.

I like asynchronous messaging solutions. I.e. using JMS. You could easily set up ActiveMQ as a network of brokers, and then rely on publish subscribe patterns. In that case, there would be no central component. There are other brokers that does this also.

Have you looked at AKKA? It is not anything near a standard, but a nische concept usefull if your application is very distributed in it's nature.

Another trend, perhaps too data centric for you, is to use distributed memory/data grids. Such as hadoop etc.

like image 2
Petter Nordlander Avatar answered Oct 17 '22 03:10

Petter Nordlander