It would be an issue in many use cases, consider the case where people
compete in a quiz and it's relevant who posted the correct answer first.
I need a framework that ensures the integrity of the central model (the
chat history), and ensures the correct synchronization of all the client
views.
Is the issue I described below inherent to Derby? Or is it something the
chat demo could resolve?
Potential issue:
User A enters a chat message (using browser/client A), the message
gets added to his view immediately, and it also gets sent to the
server. The server sends it to user/client B for update of his view.
But in the meantime user B enters a chat message, it gets added to his
view immediately - there now is message B as last message in user B's
chat history and message A as last message in user A's chat history.
Potential Solution (for certain types of web apps):
Don't have immediate client view updates.
Send the piece of data (which also is an update request) to the
server who adds it to the central model and distributes it to all
clients (incl the client of the user who created the piece of data).
Each client updates its model and view, then sends a short "I
processed the update request I got" to the server.
The server waits for the last such signal (ignoring any users who
disconnected), and then is ready for the next piece of data (the next
update request). If there are items in the queue, process those first.
This way, whichever data piece reaches the server first wins (and wins
on all clients), and the data piece that reached the server a bit
later will be processed after the first one has been reflected in each
client.
The above approach might be an option for web apps where the described
integrity is crucial (even though the approach would make the view
update in the creator's client a bit slower).
Tobi