I am working on app that primarily used in offline condition. User generate data offline and later I schedule a periodic worker that sends the data (Publish) to backend server when device is online
My publishes looks like the following (This is for user registration)
{ "event":"dbase_mob", "data":"1,0,Emmanuel,Mtali,1930,Male,0719XX,", "device_id":"34e01af81782", "publish_at":1637311191, "app_version":"2.4.1" }
The publishes gets incremental value as identifier 'pub_id'
Problems
What I did? Concerning the issue of missing publish I have implemented another worker that requests for missing publishes from the server and publish them. This is still chaotic:- Example, if a publish for creating user failed for any reason and the publish for transaction for that specific user arrive to the server it create a data dependency conflict
Questions How can I get rid of additional sync of pub_id How can I ensure no missing publishes
Curious
How some apps like Instagram handle publishing offline data efficiently
The data generate in offline can be in different table or set a flag to determine if it synced or not and update when it successfully push to server.
But still it a really tough topic, there are many things need to handle like will your app install in multiple devices? if so then the continuous incremental id might not work as if 2 local devices have same id and push to service how will you merge them?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.