I'm having the problem that a stomp message send to a user-destination is not received by the client. Let me explain:
In WebSocketMessageBrokerConfigurer:
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/secured/topic", "/secured/user/queue");
config.setUserDestinationPrefix("/secured/user");
..
On my stompjs client (logged in as "admin"):
stompClient.subscribe('/secured/user/queue/notifications'
, function (output) {
console.log(output);
});
In the log:
Processing SUBSCRIBE /secured/user/queue/notifications id=sub-0 session=d74f49b3-bb63-580f-b862-81647cc712b3
And java code to send the message:
simpMessagingTemplate.convertAndSendToUser(
"admin", "/secured/user/queue/notifications", out);
Which results in log:
Processing MESSAGE destination=/secured/user/queue/notifications-userd74f49b3-bb63-580f-b862-81647cc712b3 session=null payload={"from":"server","text":"hello","recipient":"admin","time":"13:29:10"}
-
But no message is printed in the console log.
As you can see the sessionid is the same in the subscribe and send step. But i don't understand why the client doesn't get the message. Note that message without user destination are working correctly.
Can anybody offer me a helping hand?
I got it working trying many variations, I'm only not sure why it working, but i don't complain. What i did:
In configureMessageBroker (WebSocketMessageBrokerConfigurer) (this really confuses me goes against all samples i read):
config.enableSimpleBroker("/secured/topic", "/secured/queue", "/secured/user");
convertAndSendToUser (the "/secured/user" + username is added by convertAndSendToUser):
simpMessagingTemplate.convertAndSendToUser( "admin", "/queue/notifications", out);
and my subscribe on the client (not really happy about adding username here..):
stompClient.subscribe("/secured/user/"+userName+"/queue/notifications"
, function (output) {
But it works ;-)
[edit] Trace logging makes it easier to understand what is going on:
<Logger name="org.springframework.messaging" level="trace" additivity="false">
<AppenderRef ref="Console"/>
</Logger>