I have a Java Play Framework 2.5 project where periodically I have to update the registries of our customer. I can't do a simple SQL insert/update because I to do some logic and operation on every single row.
I ended up uploading on my website an xlsx
file (asynchronous way) with JS and then working on it with Apache POI.
My only problem is that I don't know how to inform the user who uploaded the file on the progress of the processing of the file.
I'll like to simple show every 10% a message with the percentage.
I've searched on the net, I think the best way is to use websockets with Akka (BroadcastHub
), but i'm only finding examples in Scala or for 2-way communication that send output only when an input is received.
If you know a different way to do it you are welcome!
I suggest you look at https://github.com/playframework/play-java-websocket-example : It gives an example of a websocket and an actor interaction.
In your case, you would create a named actor (useractor-someid), which manages the mutations. The controller then would reference the same actor (or have an other actor send to useractor-someid), so that it can fetch the status. I suggest you use a JsonNode flow, so you can send / receive JSON in the websocket connection.