Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: best practice to update data online when internet can be interrupted


I have 2 applications:

  • desktop (java)
  • web (symfony)

I have some data in the desktop app that must be consistent with the data in the web app.
So basically I send a POST request from the desktop app to the web app to update online data.

But the problem is that the internet cannot always be available when I send my request and in the same time I can't prevent the user from updating the desktop data
So far, this is what I have in mind to make sure to synchronize data when the internet is available.

enter image description here Am I on the right direction or not ?
If not, I hope you guys put me in the right path to achieve my goal in a professional way.
Any link about this kind of topics will be appreciated.

like image 406
SlimenTN Avatar asked Nov 07 '22 04:11

SlimenTN


1 Answers

In this case the usefull pattern is to assume that sending data is asynchronous by default. The data, after collecting, are stored in some intermediate structure and wait for a sutable moment to be send. I think the queue could be useful because it can be backend with a database and prevent data lost in case of the sending server failure. Separate thread (e.g. a job) check for data in the queue and if exists, read them and try to send. If sending was performed correctly the data are removed from queue. If failure occurs, the data stays in queue and an attempt will be made to send them next time.

like image 160
piradian Avatar answered Nov 14 '22 22:11

piradian