-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fault-tolerant messaging for server-client communication #20348
Comments
UPD: Vaadin already uses some caching:
atmosphere.addInitParameter(ApplicationConfig.BROADCASTER_CACHE,
UUIDBroadcasterCache.class.getName());
What we need else is server-side buffer that stores server response messages and re-sends them to client, if these messages are not yet confirmed by client. Currently the server doesn't re-send the response, if the client resends the request once again (some deviations from real logic are possible):
We have to avoid the ignoring of the request that client re-sends. Server should re-send the response in such cases. |
Describe your motivation
Vaadin doesn't store any information about messages that are sent from server to client (and vice versa) and triggers a full page reload in browser, when the server detect a mismatch between UI state on client and server, e.g. when message is lost.
This may happen due to various reasons, but those caused by network issues / message loose, can be reliably eliminated by implementing two-side message buffer for already sent, but not-yet-confirmed messages. Server can store an ordered log/buffer of UIDL messages and client can store a similar log/buffer for RPC message. The messages are preserved in buffer until a consumer (may be a server or client, depending who sends the message) confirms that it has received the message in the next request, then the producer deletes this message from the buffer.
Describe the solution you'd like
Flow Client (
MessageSender
) and Flow Server (ServerRPCHandler
) have the logs (buffers) of ordered messages that producer (either Flow server for UIDL or Flow client for RPC) has sent to consumer.These logs has message JSONs mapped to the sync ID or client ID. These IDs are already being used for detecting a out of sync.
Producer stores a message in the log until it gets a confirmation from the consumer.
Once a consumer sends another request (e.g. client sends another RPC for another user action), then the producer checks if this request has a confirmation for previously sent message (e.g. for the previous UIDL update that server sent to client). If the confirmation is there, then server deletes the corresponding message from the buffer, otherwise it re-sends it again in the current response along with the current UI update. Then the consumer receives two responses instead of one (if, of course, message is not lost again).
This is illustrated by the sequence diagram below: first UIDL message is logged, then deleted after confirmation. Second UIDL message is lost and server re-sends it again after action 3. Then browser receives two UIDL messages (2 and 3), updates the UI and sends the confirmation in the next request.
Acceptance Criteria:
Additional context
Better to do it in two steps:
Target Vaadin release - 24.6, but can be picked to older versions.
The text was updated successfully, but these errors were encountered: