I'm very new to web apps so this might be a really silly question. Basically I want to have a web app which synchs with a database, it also should be able to send data which will be synched with a database.
My question is about downtime. If the web app loses its net connection, is there a w开发者_如何学编程ay for it to save the information inputted into it until it regains a net connection and can synch it to th database?
Thanks for any help!
Ideally you want to write an http fifo queue using HTML5 local storage. It's very overkill in most situations but at work we have a native client library for iOS, WP7, Android and Javascript and all offer persistent queuing and reliable delivery so they have to handle the server connection dropping out for whatever reason.
Get/Post -> In to In-Memory queue -> Save to storage -> Send -> remove from storage -> raise "sent" callback.
If a message fails to send then leave it in storage and requeue it in memory.
Have a timer event that kicks the queue every few seconds (As well as kicking it when messages are added/removed). Limit that max simultaneous connections (Http should be 2 per client).
Then each time your web app is loaded try read all items in local storage back in to the In-Memory queue.
Then you have persistent/reliable queuing and won't lose any messages :)
精彩评论