spring-messaging

Check auth while sending a message to a specific user by using STOMP and WebSocket in Spring

馋奶兔 提交于 2019-11-28 17:20:26
I'm developing a realtime notification system in Spring 4 by using a build-in Message Broker , and STOMP over WebSocket . I would like to be able to send messages to a specific user, according with his username. In order to achieve this goal, I'm using the convertAndSendToUser method of org.springframework.messaging.simp.SimpMessagingTemplate class, as follows: private final MessagingTemplate messagingTemplate; @Autowired public LRTStatusListener(SimpMessagingTemplate messagingTemplate) { this.messagingTemplate = messagingTemplate; } @Scheduled(fixedDelay=5000) public void sendMessages

Does Spring @SubscribeMapping really subscribe the client to some topic?

爱⌒轻易说出口 提交于 2019-11-28 16:22:47
I am using Spring Websocket with STOMP, Simple Message Broker. In my @Controller I use method-level @SubscribeMapping , which should subscribe the client to a topic so that the client would receive the messages of that topic afterwards. Let say, the client subscribes to the topic "chat" : stompClient.subscribe('/app/chat', ...); As the client subscribed to "/app/chat ", instead of "/topic/chat" , this subscription would go to the method which is mapped using @SubscribeMapping : @SubscribeMapping("/chat") public List getChatInit() { return Chat.getUsers(); } Here is what Spring ref. says: By

Spring Websockets @SendToUser without login?

旧城冷巷雨未停 提交于 2019-11-28 08:25:34
I have a simple spring application with websocket functionality and everything works so far. Now I want to send a message from my server to a specific client using the @SendToUser annotation. This gives me the error "Ignoring message, no principal info available". I understand that i have no login whatsoever on my server, so every user is "anonymous" and does not have a principal (I am not using spring security for now). But every user has a session-id. Isnt it possible to use the session id somehow to differentiate between users? How can i achieve that so my users get a principal which

Check auth while sending a message to a specific user by using STOMP and WebSocket in Spring

天大地大妈咪最大 提交于 2019-11-27 20:02:39
问题 I'm developing a realtime notification system in Spring 4 by using a build-in Message Broker , and STOMP over WebSocket . I would like to be able to send messages to a specific user, according with his username. In order to achieve this goal, I'm using the convertAndSendToUser method of org.springframework.messaging.simp.SimpMessagingTemplate class, as follows: private final MessagingTemplate messagingTemplate; @Autowired public LRTStatusListener(SimpMessagingTemplate messagingTemplate) {

Spring Websockets @SendToUser without login?

风流意气都作罢 提交于 2019-11-27 01:53:25
问题 I have a simple spring application with websocket functionality and everything works so far. Now I want to send a message from my server to a specific client using the @SendToUser annotation. This gives me the error "Ignoring message, no principal info available". I understand that i have no login whatsoever on my server, so every user is "anonymous" and does not have a principal (I am not using spring security for now). But every user has a session-id. Isnt it possible to use the session id