Reputation: 63
I'm making a little Java gRPC project, where i use multiple gRPC services. One of such services is a bi-directional stream. I'd like to know how can I be sure that a message from the "server" is arrived to all the clients. For example, let's say I sent a message "hello" from the server to all the clients, is there a way to be sure that all the clients has received the "hello" message? It is critical to me to go on with the server only when i'm sure that all the clients received that message.
Upvotes: 1
Views: 734
Reputation: 26464
Use another message. The clients essentially need to acknowledge the server's message, and this is best done using a message from the client to the server. How the server's message is identified varies in different systems, sometimes using individual unique ids, sometimes using version ids which imply "everything up unto this point" is processed, and sometimes just required in-order "ACK" messages with no addition details.
You should be wary of accidental races though. For example, if you use a plain ACK message the server shouldn't consider all server messages on that stream to have been acknowledged. Instead, the ACK should apply just to the oldest unacknowledged message.
Upvotes: 1