0

I have to deploy some Java servers in a bunch of different networks. For each server, I need to monitor its status and send it tasks to be executed in that specific server. Something like distributed workers.

This servers would be used from different platforms and languages so I need to find a way to communicate with them and obtain the needed information. Which is the best way to do this? I've been reading about use JSONs to communicate with my servers but I'm trying to figure out if there is a better approach.

Another solution could be to have a web dashboard and control all through web petitions but I prefer the servers to be standalone. Any ideas on what I can do?

David Moreno García
  • 4,423
  • 8
  • 49
  • 82

2 Answers2

1

If multiple platforms are involved, web services are probably your best bet. You can have you java servers expose web services (for status and task execution) and you can call them from anywhere/any system.

Mahesh Guruswamy
  • 769
  • 5
  • 15
  • And, do I need a webserver or a particular framework in my servers? That sounds really interesting. – David Moreno García May 17 '13 at 17:46
  • 1
    You need a server which can respond to/issue HTTP requests. Spring Web services is a good webservices framework for java. Here is a tutorial for the creating REST services with Spring http://static.springsource.org/spring/docs/3.0.0.M3/reference/html/ch18s02.html – Mahesh Guruswamy May 17 '13 at 17:49
  • I thought that Spring was oriented to create bigger websites or services. This is going to be a console server. A daemon. Is Spring good for this? – David Moreno García May 17 '13 at 17:55
  • 1
    Spring can be used in a stand alone mode as well. Not necessarily just for web sites/JEE applications. Check out this discussion http://stackoverflow.com/questions/1292171/deploy-java-web-service-without-using-web-server – Mahesh Guruswamy May 17 '13 at 17:59
1

At the moment I would suggest REST interfaces for your Java server. Since REST with Json is easy to implement in other languages too and you can even use HTML and JavaScript to write a Monitor client. So from my point of view this is the most flexible solution.

An other solution would be to use XMPP to "talk" with the server and "ask" them about there state. I remeber this as a solution for machine to machine communication, but this was before the Json and REST boom so I would not suggest to go with this.

When your other platforms consists of Java and C# mostly SOAP could also be a solution, since there are good code generator for both languages which can create the WSDL from code and vice versa. But its kinda difficult to use SOAP in JavaScript (as far as I experienced) and maybe other languages have the same problem with SOAP.

mszalbach
  • 10,612
  • 1
  • 41
  • 53
  • REST sounds really promising but I can't find a decent tutorial/article to standalone/console Java apps. Could you point me to one? This really worth a try ^^ – David Moreno García May 17 '13 at 17:44
  • You could have a look at http://stackoverflow.com/questions/8277409/jax-rs-with-embedded-server or http://www.adam-bien.com/roller/abien/entry/the_executable_feel_of_jax for some simple example. When your server is sitting in an application server or a java container you could check for spring or JavaEE REST webservice classes. – mszalbach May 17 '13 at 19:02
  • I'm taking a look at JAX-RS but I have a question. The idea is to have, maybe, some servers in the same computer (different ports). Is this possible with Jersey and JAX-RX. Also, seems that I would need a webserver (Tomcat for example) to deploy my servers. Is this strictly necessary? – David Moreno García May 17 '13 at 19:33
  • 1
    A webserver like Tomcat or Jetty make this easier but like the stackoverflow link I posted you could use the jersey-simple-server to not rely on a complete webserver. Or you could use a webserver which can be used in embedded mode like jetty. – mszalbach May 17 '13 at 19:46
  • Thanks for your answer. I think that I'm going to use Spring to develop a dashboard and underneath a tracker accessible via web. What do you think about this? – David Moreno García May 17 '13 at 19:54
  • 1
    I have not much experience with Spring but since it has all the JavaEE features and it can be used in a Tomcat or Jetty without much effort (if you want to use one sometimes later) I think this is a justifiable solution :). – mszalbach May 17 '13 at 20:06