views:

706

answers:

5

I have a Java application which is a long running process (lets call it a "server"). I have to write a desktop GUI (most likely in Swing), lets call it a "client", which can connect to this application and:

  1. display status updates from the application
  2. give specific "manually triggered" commands to the application

Each interaction (conversation thread) between the client and the server would be short, but might involve a few messages up and down. What are the various options to implement something like this? Speed is not a huge concern for me; I am more interested in something where I can evolve the conversation protocol without being bogged down by the plumbing details. The options I have in mind now are sockets, RMI, JMS and JavaSpaces.

A: 

I do this kind of stuff for many years with XML-RPC. I like it because it is very simple and gets you within 15 minutes running. It is all http and simple XML.

Norbert Hartl
A: 

If it is an option to extend the server by a RESTful API, that would probably be the most easy one to use by a client. After simply stating the API in URL terms you can switch easily your client to other languages if needed.

wr
A: 

I've solved this problem with sockets using ObjectInputStream and ObjectOutputStream for serialization commands.

For protocol you need different objects-commands (Command pattern can be useful here). All these objects should be serializable. Then you can simply send/receive commands. IMHO the easiest way (in technological side and in implementation).

Roman
The question was only partially answered by suggesting ObjectInputStream. binil does not want to be bothered with plumbing details.
Richard
Thats right; I would prefer to describe the conversation as abstractly as possible.
binil
+1  A: 

Take a peak at Apache Camel (Java). It supports all the options you mention and also allow for rules when routing messages.

Install either stand-alone or it comes included with Apache ActiveMQ (JMS broker).

c0dem4gnetic
A: 

I agree with @Norbert Hartl. Apache has a dead simple XMLRPC implementation that you can use with Apache HTTPClient. The library also has an example of using a server to receive XMLRPC requests.

spdaly