Reputation: 13779
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:
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.
Upvotes: 2
Views: 2981
Reputation: 942
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).
Upvotes: 1
Reputation: 1260
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.
Upvotes: 0
Reputation: 66156
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).
Upvotes: 0
Reputation: 2859
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.
Upvotes: 0
Reputation: 10841
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.
Upvotes: 0