6

I'd like to hear your opinion, what will be the best option to implement websocket queue using Spring and STOMP protocol, when there is no user session (stateless, restful web app).

Based on this explanation: https://stackoverflow.com/a/31577152/3076403 I know that Spring will use the queue when we use simpMessagingTemplate.convertAndSendToUser(...) method and pass the username associated with session id. Otherwise it will use a topic, where all subscribed clients will eventually read the same message returned from the server.

In my case, I have a RESTful app with Angular UI part. I want to implement the progress bar on the UI side. Initially UI sends the message to the server, with given ID that was determined earlier, ex: {id: 20}.

Then, the UI have to listen on the changes of the returned model for the particular ID and calculate the progress of internal processing. The message back can look like this: {id: 20, timeLeft: 30, totalTime: 60}

So for each Angular app that will subscribe to the websocket channel on the server, it should give different results.

As I have no session in the app and have to implement the websocket queue on the server, do you know other solutions using Spring and STOMP protocol different from that one I recently came up with:

Spring: simpMessagingTemplate.convertAndSend("/ui/progress/"+id, ...)

UI ng-stomp: $stomp.subscribe("/ui/progress/"+id, function(...))

I know that this will be a "fake" topic, rather than queue. Any comments and ideas appreciated.

Community
  • 1
  • 1
Thomas Weglinski
  • 1,094
  • 1
  • 10
  • 21

0 Answers0