1
votes

I have a problem: i have created a notification system with spring boot, stomp, sockjs. I have a server Java and a javascript client. I have to send some notification from server to clients but: when a client is online, i send him the notification --> it works! (I use stomp and sockjs) When a client is offline i have to save the notification and i'll send him the notification saved when he will return online..Any suggestion about?? How can i do that? I have read something about ActiveMQ, but where can i find some accurate tutorial? Thank you in advance

1
Hi, Could you please share the code or reference where your able to send notifications to multiple online/connected users which is implemented in Spring MVC, stomp, sock JS? Thanks in advance. Am facing similar issue faced here: stackoverflow.com/questions/33910639/… - Delli Kilari

1 Answers

0
votes

post your code, configs... you can do that by posting notifications to a destination (topic with durable subscription if you have multiple clients for the same notification type or a queue if you have a notification for every client) and when js client connects to that destination he receive them.

You can work with websockets like this https://github.com/apache/activemq/tree/master/activemq-web-demo/src/main/webapp/websocket

https://github.com/jmesnil/stomp-websocket/blob/master/example/chat/index.html

http://activemq.apache.org/websockets.html

There are many libs and examples https://github.com/krukow/stomple/blob/master/example/transactional-chat.html

ActiveMQ Extensions to STOMP You can add custom headers to STOMP commands to configure the ActiveMQ protocol. Here are some examples:

CONNECT client-id string Specifies the JMS clientID which is used in combination with the activemq.subcriptionName to denote a durable subscriber.

http://activemq.apache.org/stomp.html

var connect = function () {
   var socket = new SockJS( webSocketUrl );
   stompClient = Stomp.over( socket );

   stompClient.connect( {"client-id": "my-client-id"},, function ( frame ) {

      console.log( 'Connected: ' + frame );

      stompClient.subscribe( topic, function ( message ) {
        .....
        .....
      }, {"activemq.subscriptionName": "my-client-id"});
   }, function(frame) {
        console.log("Web socket disconnected");
   });
 }