spring-messaging

Spring security websocket and HTTP authentication/authorization

本秂侑毒 提交于 2019-12-22 05:11:59
问题 Summary I would like to implement websocket communication over STOMP. Authenticate The user in the time of the first (HTTP request) websocket handshake and use this Principal for authorizing websocket messages later. Problem The system authenticates the client at the first time when it tries to connect to the websocket endpoint (the time of HTTP handshake). My spring security filter and Authentication provider does its job and authenticates the client properly. After this I can check that the

Send STOMP ERROR from Spring Websocket program

五迷三道 提交于 2019-12-21 21:37:29
问题 I have a Spring Websocket Stomp application that accepts SUBSCRIBE requests. In application I have a handler for SUBSCRIBE, that is, @Component public class SubscribeStompEventHandler implements ApplicationListener<SessionSubscribeEvent> { @Override public void onApplicationEvent(SessionSubscribeEvent event) {} } that I use to validate subscription. I would check something in the onApplicationEvent and send STOMP ERROR message back to client from this function. I found this recipe How to send

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

一世执手 提交于 2019-12-20 08:29:15
问题 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 :

Sending Error message in Spring websockets

你说的曾经没有我的故事 提交于 2019-12-18 17:26:14
问题 I am trying to send error messages in Spring websockets with STOMP over SockJS. I am basically trying to achieve which is being done here. This is my Exception Handler @MessageExceptionHandler @SendToUser(value = "/queue/error",broadcast = false) public ApplicationError handleException(Exception message) throws ApplicationError { return new ApplicationError("test"); } And I am subscribing to stompClient.subscribe('/user/queue/error', stompErrorCallback, {token: accessToken}); User in my case

How to send plain text JmsMessage with empty header

江枫思渺然 提交于 2019-12-13 02:56:14
问题 I want to send a message to an activeMQ and receive it via MQTT.js in the frontend. jmsTemplate.convertAndSend("topic", "Hello World!"); I am getting the message, but with a header, that I can not decode. S�A S�)�x-opt-jms-destQ�x-opt-jms-msg-typeQ Ss� f �/ID:myID@�topic://myTopic@@@@� j��< St�e Sw� Hello World! Now I am trying to remove the header from my message. This thread mentions the targetClient property, but this doesn't seam to work with a topic: Spring JMS Template - remove RFH

Error handling while using STOMP simple broker

孤街醉人 提交于 2019-12-11 18:33:28
问题 I am creating simple STOMP broker using @EnableWebSocketMessageBroker . When RuntimeException happens in @MessageMapping method I would like to receive STOMP ERROR frame, but it doesn't work like that by default. It seems that ERROR frame is not supported in simple broker: https://github.com/spring-projects/spring-framework/blob/master/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessageType.java#L28-L44 On the other hand, there is a mechanism to send ERROR frames

How to register stomp subscriptions in Spring

前提是你 提交于 2019-12-11 15:23:11
问题 I want to control stomp subscription in my Spring application with spring-messaging v.4.2. This is my Spring app configuration for stomp: @Configuration @EnableWebMvc @ComponentScan(basePackages = "com.myapp") @EnableWebSocketMessageBroker @EnableAsync @EnableScheduling public class Config extends AbstractWebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableSimpleBroker("/queue", "/topic"); config

How to use ExecutorSubscribableChannel

£可爱£侵袭症+ 提交于 2019-12-08 08:19:31
问题 Related with the question autowire simpmessagingtemplate I am having problem the class ExecutorSubscribableChannel. I want the server to send a asynchronous message to the browser. How can I use properly ExecutorSubscribableChannel ? Example: public class GreetingController { @Autowired private SimpMessagingTemplate template; public void setTemplate(SimpMessagingTemplate template) { this.template = template; } @MessageMapping("/hello") @SendTo("/topic/greetings") public Greeting greeting

How configure the Spring Sockjs Java Client message converters

只谈情不闲聊 提交于 2019-12-07 23:06:53
问题 I have one SockJS Java client that use STOMP. Is base on this https://github.com/rstoyanchev/spring-websocket-portfolio/blob/master/src/test/java/org/springframework/samples/portfolio/web/load/StompWebSocketLoadTestClient.java. My code: package mx.intercommunication.websocket.stompclient; import org.springframework.messaging.converter.StringMessageConverter; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaders; import org

How configure the Spring Sockjs Java Client message converters

我怕爱的太早我们不能终老 提交于 2019-12-06 12:19:20
I have one SockJS Java client that use STOMP. Is base on this https://github.com/rstoyanchev/spring-websocket-portfolio/blob/master/src/test/java/org/springframework/samples/portfolio/web/load/StompWebSocketLoadTestClient.java . My code: package mx.intercommunication.websocket.stompclient; import org.springframework.messaging.converter.StringMessageConverter; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaders; import org.springframework.messaging.simp.stomp.StompSession; import org.springframework.messaging.simp.stomp