1

I want to write a Java Client/Server application which should do the following:

  • Client connects to to one of two servers
  • Server sends a text file or its content to the client
  • User edits the file
  • Client sends the file back to both servers simultaneously and reliably
  • Client closes the application

Bonus: One of these servers might be down at the time of the transmission, so it needs to receive the file on startup.

What architecture or framework would be good and lightweight to enable this? Is JGroups a good start?

edit: I have to assume the following minimal network:

  • One or more clients start the application but must not be allowed to edit the file at the same time.
  • There are one or more servers, of which at least one is always active (which one is sort of random)
  • The client has a .xml file with all server addresses
FoxDie
  • 11
  • 2
  • If this is meant as a clustered solution (in other words: both servers are in the same network) consider using a shared filesystem, this is by far the easiest solution. – nablex Oct 15 '13 at 09:46
  • This would certainly be the most comfortable but unfortunately this is not an option for me. Thanks anyway. – FoxDie Oct 15 '13 at 12:28

1 Answers1

0

A JMS framework (ActiveMQ) can solve your problem using a queue and a topic:

  • client posts a message on a queue where both server listen, asking for the file
  • only one server receives this requests and sends the file to the client
  • client edits the file
  • client sends the edited file on a DURABLE topic where both servers are subscribed

Using a durable topic is important so offline subscribers (your servers) get the file once they reconnect.

coyote
  • 169
  • 4
  • Sounds interesting. I will look into this. Where is that durable topic saved? Because it mght be a problem if that happens on the Client since I want him to be able to "fire-and-forget" or simply quit after he sent the file. – FoxDie Oct 16 '13 at 07:07
  • Both topic and queue will be managed by the JMS broker (e.g. ActiveMQ). This works as a separate application that manages all this communication. – coyote Oct 16 '13 at 11:41
  • Ok. SO I guess since my client does not stay online, the broker has to be on all servers, since I can only assume that at least one of them stays active. SO I guess I would create a point-to-point connection from my Client to said server, which will in turn act as a broker to notify all other servers of the new file. Does that make sense? – FoxDie Oct 16 '13 at 11:58
  • The JMS broker will be on one machine only (can be one of your servers, or a separate machine which is known to stay online). – coyote Oct 16 '13 at 12:37
  • I think I got that but you see, the problem is that at the bare minimum (at which it also has to work) there will only be the client and the 2 servers. And of these 2 servers I can't safely say which one is reachable. So I guess I have to implement it on both servers as a kind of a fail-safe. – FoxDie Oct 16 '13 at 12:39