This is a very simple implementation of chat history. It has a couple of drawbacks:
it's not resilient for very very high loads - in such case, messages will accumulate in Agent's queue and they will block get requests
I am not sure but I think there is no guarantee that the order of messages in the history will be the same as the order seen in real-time. E.g. we have two processes A and B, A receives a message from the client side, B receives a message from the client side, A saves to the history, B saves to the history, then I believe, for some reasons B can broadcast its message to other processes before A will do this.
I think that we don't have to worry about the first one until we notice this is a problem. I added a simple try catch not to break the whole chat.
The second one sounds a bit unlikely. To solve it, we would probable have to record time of message receival and reorder messages on the frontend (if needed).
This is a very simple implementation of chat history. It has a couple of drawbacks:
get
requestsI think that we don't have to worry about the first one until we notice this is a problem. I added a simple try catch not to break the whole chat.
The second one sounds a bit unlikely. To solve it, we would probable have to record time of message receival and reorder messages on the frontend (if needed).