Fix @SubscribeMapping MESSAGE response destination
Prior to this commit, @SubscribeMapping mapped methods (backed with @SendTo* annotations, or not) would send MESSAGEs with the wrong destination. Instead of using the original SUBSCRIBE destination, it would use the lookup path computed from the configured prefixes in the application. This commit fixes this issue - now @SubscribeMapping MESSAGEs use the original SUBSCRIBE destination. Issue: SPR-11648
This commit is contained in:
@@ -24,6 +24,7 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.core.MessagePostProcessor;
|
||||
import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
@@ -158,7 +159,8 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return new String[] { defaultPrefix + inputHeaders.getDestination() };
|
||||
return new String[] { defaultPrefix +
|
||||
inputHeaders.getHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER) };
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -357,7 +357,6 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
|
||||
String matchedPattern = mapping.getDestinationConditions().getPatterns().iterator().next();
|
||||
Map<String, String> vars = getPathMatcher().extractUriTemplateVariables(matchedPattern, lookupDestination);
|
||||
|
||||
headers.setDestination(lookupDestination);
|
||||
headers.setHeader(DestinationVariableMethodArgumentResolver.DESTINATION_TEMPLATE_VARIABLES_HEADER, vars);
|
||||
message = MessageBuilder.withPayload(message.getPayload()).setHeaders(headers).build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user