I am trying to something similar to this "Path variables in Spring WebSockets @SendTo mapping" But I want to send a table name as additional information to @SubscribeMapping("/topic/data"). "tablename" can be anything based on my need(what I want to set), it should concatenate @SubscribeMapping("/topic/data/{tablename}") and on the server side, I would like to access the tablename to get the data from the database. I have tried the solution mentioned in the above post lien @DestinationVariable but I think I am missing something.
Asked
Active
Viewed 2,444 times
1 Answers
2
on the server side :
@SubscribeMapping("/getviewschema/{tablename}")
public JSONObject getViewSchema(@DestinationVariable String tablename) throws Exception
{
DataManager manager = new DataManager();
return manager.getViewJSONSchema(tablename);
}
On the client side
socket.stomp.subscribe("/app/getviewschema/"+service.tablename,function(data)
{
listenerview.notify(JSON.parse(data.body));
});

Bubble
- 57
- 9
-
Thank you for this answer, it actually works. I missed it in the docs, it was here: https://docs.spring.io/spring/docs/5.0.x/spring-framework-reference/web.html#websocket-stomp-handle-annotations – destan Mar 29 '18 at 19:55