org.springframework.messaging.simp.annotation.support

## Class SubscriptionMethodReturnValueHandler

- java.lang.Object
- - org.springframework.messaging.simp.annotation.support.SubscriptionMethodReturnValueHandler

- All Implemented Interfaces:
    HandlerMethodReturnValueHandler

      public class SubscriptionMethodReturnValueHandler
      extends Object
      implements HandlerMethodReturnValueHandler

  A `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.

  Since:
    4.0
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> messagingTemplate)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SubscriptionMethodReturnValueHandler

          public SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> messagingTemplate)

      Parameters:
        `messagingTemplate` - a messaging template for sending messages directly to clients, e.g. in response to a subscription

  - ### Method Detail

    - #### supportsReturnType

          public boolean supportsReturnType(MethodParameter returnType)

      Description copied from interface: `HandlerMethodReturnValueHandler`
      Whether the given method return type is supported by this handler.
      Specified by:
        `supportsReturnType` in interface `HandlerMethodReturnValueHandler`
      Parameters:
        `returnType` - the method return type to check
      Returns:
        `true` if this handler supports the supplied return type; `false` otherwise

    - #### handleReturnValue

          public void handleReturnValue(Object returnValue,
                                        MethodParameter returnType,
                                        Message<?> message)
                                 throws Exception

      Description copied from interface: `HandlerMethodReturnValueHandler`
      Handle the given return value.
      Specified by:
        `handleReturnValue` in interface `HandlerMethodReturnValueHandler`
      Parameters:
        `returnValue` - the value returned from the handler method
        `returnType` - 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 `true`
        `message` - the message that caused this method to be called
      Throws:
        `Exception` - if the return value handling results in an error