org.springframework.messaging.simp.annotation.support

Class SendToMethodReturnValueHandler

  • java.lang.Object
    • org.springframework.messaging.simp.annotation.support.SendToMethodReturnValueHandler
  • All Implemented Interfaces:
    HandlerMethodReturnValueHandler


    public class SendToMethodReturnValueHandler
    extends java.lang.Object
    implements HandlerMethodReturnValueHandler
    A HandlerMethodReturnValueHandler for sending to destinations specified in a SendTo or SendToUser method-level annotations.

    The value returned from the method is converted, and turned to a Message and sent through the provided MessageChannel. The message is then enriched with the session id of the input message as well as the destination from the annotation(s). If multiple destinations are specified, a copy of the message is sent to each destination.

    Since:
    4.0
    Author:
    Rossen Stoyanchev, Sebastien Deleuze
    • Constructor Detail

      • SendToMethodReturnValueHandler

        public SendToMethodReturnValueHandler(SimpMessageSendingOperations messagingTemplate,
                                              boolean annotationRequired)
    • Method Detail

      • setDefaultDestinationPrefix

        public void setDefaultDestinationPrefix(java.lang.String defaultDestinationPrefix)
        Configure a default prefix to add to message destinations in cases where a method is not annotated with @SendTo or does not specify any destinations through the annotation's value attribute.

        By default, the prefix is set to "/topic".

      • getDefaultDestinationPrefix

        public java.lang.String getDefaultDestinationPrefix()
        Return the configured default destination prefix.
        See Also:
        setDefaultDestinationPrefix(String)
      • setDefaultUserDestinationPrefix

        public void setDefaultUserDestinationPrefix(java.lang.String prefix)
        Configure a default prefix to add to message destinations in cases where a method is annotated with @SendToUser but does not specify any destinations through the annotation's value attribute.

        By default, the prefix is set to "/queue".

      • getDefaultUserDestinationPrefix

        public java.lang.String getDefaultUserDestinationPrefix()
        Return the configured default user destination prefix.
        See Also:
        setDefaultUserDestinationPrefix(String)
      • getTargetDestinations

        protected java.lang.String[] getTargetDestinations(@Nullable
                                                           java.lang.annotation.Annotation annotation,
                                                           Message<?> message,
                                                           java.lang.String defaultPrefix)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object