Received message's destination is default for resp

When an annotated handler returns a Message from a @SubscribeEvent
or @MessageMapping method and it contains no destination in its
headers, use the received message's destination as the response
message's destination.
This commit is contained in:
Andy Wilkinson 2013-06-17 15:27:32 +01:00 committed by Rossen Stoyanchev
parent 7bb3b824c3
commit f6398e14d0
1 changed files with 4 additions and 0 deletions

View File

@ -84,6 +84,10 @@ public class MessageReturnValueHandler implements ReturnValueHandler {
returnHeaders.setSessionId(sessionId);
returnHeaders.setSubscriptionId(subscriptionId);
if (returnHeaders.getDestination() == null) {
returnHeaders.setDestination(headers.getDestination());
}
Object payload = returnMessage.getPayload();
return MessageBuilder.fromPayloadAndHeaders(payload, returnHeaders.toMessageHeaders()).build();
}