Thursday, 25 November 2021

Architecture to publish offline data from android app to backend

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

enter image description here

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" }

  • event - describes the type of event database, transaction etc
  • data - carry the actual payload the first field is pub_id, other carry additional info
  • device_id - unique identifier given to a device
  • publish_at - when this was publish was created
  • app_version - :)

The publishes gets incremental value as identifier 'pub_id'

Problems

  • I need to sync the incremental value (pub_id) between server and app. Why? The app can be removed from the device! Installing the new app require publishes to continue from the last point
  • Any failure to process a publish on the backend service makes hard to debug issues on the client app. (No chance for mistake)
  • Edge case can happen where publish can move from say 100 .. 102 skipping the order creating a gap that the backends interprets as a missing publish!

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



from Architecture to publish offline data from android app to backend

No comments:

Post a Comment