public class SubscriptionMethodReturnValueHandler extends Object implements HandlerMethodReturnValueHandler
HandlerMethodReturnValueHandler for replying directly to a subscription. It
supports methods annotated with SubscribeMapping unless they're also annotated
with SendTo or SendToUser.
The value returned from the method is converted, and turned to a Message and
then enriched with the sessionId, subscriptionId, and destination of the input message.
The message is then sent directly back to the connected client.
| Constructor and Description |
|---|
SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> messagingTemplate) |
| Modifier and Type | Method and Description |
|---|---|
void |
handleReturnValue(Object returnValue,
MethodParameter returnType,
Message<?> message)
Handle the given return value.
|
boolean |
supportsReturnType(MethodParameter returnType)
Whether the given method return type is
supported by this handler.
|
public SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> messagingTemplate)
messagingTemplate - a messaging template for sending messages directly
to clients, e.g. in response to a subscriptionpublic boolean supportsReturnType(MethodParameter returnType)
HandlerMethodReturnValueHandlersupportsReturnType in interface HandlerMethodReturnValueHandlerreturnType - the method return type to checktrue if this handler supports the supplied return type;
false otherwisepublic void handleReturnValue(Object returnValue, MethodParameter returnType, Message<?> message) throws Exception
HandlerMethodReturnValueHandlerhandleReturnValue in interface HandlerMethodReturnValueHandlerreturnValue - the value returned from the handler methodreturnType - the type of the return value. This type must have
previously been passed to
HandlerMethodReturnValueHandler.supportsReturnType(org.springframework.core.MethodParameter)
and it must have returned truemessage - the message that caused this method to be calledException - if the return value handling results in an error