There is a simple web server on Jetty, the essence of the work is quite simple.
The client sends another user a message in the form of a json string, the server
processes it and writes the message to the database.
Upon request, the user can get the message history with another user. Question:
All this needs to be redone on the Web Socket. I don’t understand how to process requests.
If I will also write messages to the database, then how can the user check if a new message has arrived?
There is an idea to process the message, write it to the database, and then send it to the desired user, but it seems to me that this will not be correct.

  • why do you think it will be wrong? - Mikhail Vaysman
  • @MikhailVaysman I think it will work slowly, and I have no experience in this, so I decided to find out the answer from more experienced people. - Danil

1 answer 1

You can write to the database and after saving, send the message to other users. If the process of saving to the database takes too much time, then it can be carried out in parallel with the distribution.

  • Thanks for the answer. I will try. - Danil