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
-
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: http://stackoverflow.com/questions/33910639/how-to-broadcast-a-message-using-raw-spring-4-websockets-without-stomp – Delli Kilari May 06 '17 at 00:41
1 Answers
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");
});
}

- 3,885
- 2
- 12
- 20
-
-
see update, client-id string Specifies the JMS clientID which is used in combination with the activemq.subcriptionName to denote a durable subscriber. – Hassen Bennour Jan 20 '17 at 14:56
-
In this solution, if a notification is sent when the user is offline, when he become online the notification is automatic sent to him?? – Catechacha Jan 20 '17 at 17:29
-
Yep when he reconnects as a durable subscriber messages are pending in the topic. If you need them to survive to the broker restart set persistence in the broker – Hassen Bennour Jan 20 '17 at 17:32
-
-