sockjs - Spring 4 websockets dynamic MessageMapping not executed -


i'm using spring 4 websockets on tomcat 8 , have following configuration:

<websocket:message-broker application-destination-prefix="/app">     <websocket:stomp-endpoint path="/notify">         <websocket:sockjs />     </websocket:stomp-endpoint>     <websocket:simple-broker prefix="/topic" /> </websocket:message-broker> 

my spring controller has following method:

@messagemapping("/notify/{client}") public void pushmessage(@destinationvariable long client, string message) {     system.out.println("send " + message + " " + client);     template.convertandsend("/topic/push/" + client, message); } 

so i'm trying here if client 1 wants send message client 2, uses /app/notify/2. spring controller push message topic /topic/push/2.

i wrote following code in client:

var id = 1; var sock = new sockjs('/project/notify'); var client = stomp.over(sock); client.connect({}, function() {     client.subscribe('/topic/push/' + id, function(message) {         console.log(message);     }); }); 

the connection works perfectly, /project context root of application.

i have following code in client send message:

client.send('/app/notify/' + id, {}, "test"); 

both variables (client , id) accessible, i'm not getting errors part of code , can see in console message sent:

>>> send destination:/app/notify/1 content-length:4  test  

however, system.out.println() statement in controller never executed, assume there wrong controller mappings or i'm not using destination endpoints correctly (i don't understand why have specify application prefix here, not when connecting endpoint).

it seems it's unable map when using simple string message payload. when wrap message in object, works fine.

edit: stated in comments, spring comes message wrapper called textmessage class.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -