• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to write offline version for Web Application

 
Ranch Hand
Posts: 157
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Web Application for restaurant which is implemented using Struts2.0 and MYSQL as DB.

Now in case of Internet issue or other issues ,in cases where we can't access our Web Application, I want to write a offline (desktop) version for the web application to carry out POS related tasks and update the local DB. Once the connectivity restored the DB will be synced with online DB.

Can someone suggest me the design on how to achieve this.

1. How to have DB sync ? Should it be Local to --> Online DB sync or should it be two-way sync?
2. Is there any configuration I can do at DB level. Or should I write a Java program (typically a job) that keep both the DBs in sync.



Regards,
Bala.
 
Bartender
Posts: 7645
178
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The relevant technologies -mostly JavaScript APIs- are often lumped together under the term Progressive Web Apps - PWA. A bit dated, but a quick introduction can be found at https://developer.okta.com/blog/2017/07/20/the-ultimate-guide-to-progressive-web-applications.
 
Sheriff
Posts: 28394
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As for database synchronization: If you are proposing to keep a local copy of the database for use only when the remote copy is not accessible, then that local copy needs to be synchronized with the remote copy at all times. After all, the remote connection can be broken at any time without warning. Remember, when the connection is broken you will want to switch immediately to the local copy and you will expect it to be an accurate copy of the remote copy. Waiting to update your local copy until the remote copy is not available is not a useful strategy.

So your best bet would be to have the database software synchronize the two copies. Remember, this isn't a daily or weekly process, it's an ongoing instantaneous process. There are databases which can do that, so get one of them and convert your data over from your existing MySQL system if it doesn't support synchronization. And no, I wouldn't expect to be able to write Java code to do that.

Edit: Actually you might want to consider putting your application into a cloud environment which guarantees you high availability instead. Let them worry about how that gets done.
 
Saloon Keeper
Posts: 28654
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MySQL supports replication, so keeping in sync per se isn't an issue.

On the other hand, if you have 50 users with desktop copies of MySQL all trying to sync, that can be a major problem. If people update their copy of the database and it conflicts with someone else's copy of the database, then you have a "split brain" situation and you'd need to set up mechanisms to reconcile the differences.
 
Bala Tilak
Ranch Hand
Posts: 157
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Tim Moores,Paul Clapham,Tim Holloway.

I got it now.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic