Java Client-Server - Distributing Files to multiple servers

597 Views Asked by At

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
1

There are 1 best solutions below

5
coyote On

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.