I have the following contoller
@Controller
public class GreetingController
{
@MessageMapping(\"/hello\")
@SendTo(\"/topic/greetings\")
I ran your code and instead of sending simple string you should send object so instead of
this.template.convertAndSend("/topic/greetings", "message");
should be
this.template.convertAndSend("/topic/greetings", messageObject);
and your object should have some method to access content like
MessageObject.getConent();
otherwise you can always use toString()
and your js should be
stompClient.subscribe('/topic/greetings', function(greeting){
console.log(JSON.parse(greeting.body).content);
});
notice content on the end of received object
@RequestMapping(path="/meeting",method=RequestMethod.POST)
can not be used because it is a @Controller
not a @RestController