Spring websocket send message from a queue to a user convertAndSendToUser not working
<p>I have a scenario where I want the users to subscribe to a fixed websocket endpoint and need not mention queuename or topic while subscribing. I want to handle the logic inside a controller for getting their messages from their respective queues and send back to each user .
Something like this I want to achieve:-</p>

<p>My client code is first connecting to a websocket endpoint /websocket:-</p>

<pre><code>client.connectToServer( aWebsocketHandler, URI.create( "wss://host.com/websocket" ) );
</code></pre>

<p>Then sending a STOMP connect and subscribe frame over websocket</p>

<pre><code>STOMP connect frame :-
accept-version : 1.1
heart-beat : 100000,0

STOMP subscribe frame  :-

destination : /app/fixed 
id : 123
ack : auto
receipt  : 123456
</code></pre>

<p>The Server side code controller which is working is :-</p>

<pre><code>@SubscribeMapping ( "fixed" )
    public void handle( Principal principal ) {
        System.out.println( "principal.getName();" + principal.getName() );
        String queueName = Helper.getClientToQueueMap().get( principal.getName() );
        // in loop just for testing
        while(true){

            Object o = rabbitTemplate.receiveAndConvert(queueName);
            if ( o != null ) {
                System.out.println( "Returning mesg**" + o.toString() );
                simpMessagingTemplate.convertAndSend( "/app/fixed", o.toString() );
            }
            try {
                Thread.sleep(3000);
            } catch ( InterruptedException e ) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } 
            }
       }
       }
</code></pre>

<p>My web configuration has following :-</p>

<pre><code>@Override
    protected void configureStompEndpoints( StompEndpointRegistry registry ) {
        registry.addEndpoint( "/websocket" ).setAllowedOrigins( "*" );

    }

    @Override
    public void configureMessageBroker( MessageBrokerRegistry config ) {
        config.enableStompBrokerRelay( "/topic/", "/queue/", "/exchange/" )
        config.setApplicationDestinationPrefixes("/app");
        config.enableSimpleBroker("/app");
    }
</code></pre>

<p>Now I want to modify this code to send messages from a queue to its respective specific user. And even though every user will subscribe to same end point /app/fixed ,no messages should be shared among them.
Going through several posts I found that client can subscribe to /user/queue/fixed and in the controller I use convertAndSendToUser to send to specific user</p>

<pre><code>simpMessagingTemplate.convertAndSendToUser( principal.getName(), "/queue/fixed", o.toString() );
</code></pre>

<p>But this doesn't work . Since I am subscribing to /user/queue/fixed this controller handle method with @SubscribeMapping ( "fixed" ) never gets called. Can someone help me what I am doing wrong ?</p>