Prior to this commit, the only way to override the destination to send the response of message handling methods was by using @SendTo or @SendToUser, which doesn't allow building dynamic destinations.
The added ResponseMessage return type brings more flexibility when specifying the response message, which can be created using a builder, e.g
@MessageMapping("/dest")
public ResponseMessage<String> handle() {
return ResponseMessage.destination("/queue/dest1").toUser("sergi").body("hi");
}
Other examples:
new ResponseMessage<String>("hi there", "/topic/dest1");
ResponseMessage.destination("/topic/dest1").body(PAYLOAD);
ResponseMessage.destinations("/queue/dest1", "/queue/dest2").toUser(USERNAME).body(PAYLOAD);
ResponseMessage.destination("/queue/dest1").toCurrentUser().body(PAYLOAD);
ResponseMessage.destination("/queue/dest1").toCurrentUserNoBroadcast().body(PAYLOAD);
Issue: SPR-12170
Comment From: salmar
I have signed and agree to the terms of the SpringSource Individual Contributor License Agreement.
Comment From: pivotal-issuemaster
@salmar Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: rstoyanchev
Closing outdated, as per discussion under #16784.