org.springframework.messaging.core

Class AbstractMessageSendingTemplate<D>

  • java.lang.Object
    • org.springframework.messaging.core.AbstractMessageSendingTemplate<D>
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String CONVERSION_HINT_HEADER
      Name of the header that can be set to provide further information (e.g.
      protected Log logger 
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      void convertAndSend(D destination, java.lang.Object payload)
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message and send it to the given destination.
      void convertAndSend(D destination, java.lang.Object payload, java.util.Map<java.lang.String,java.lang.Object> headers)
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and send it to the given destination.
      void convertAndSend(D destination, java.lang.Object payload, java.util.Map<java.lang.String,java.lang.Object> headers, MessagePostProcessor postProcessor)
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers, apply the given post processor, and send the resulting message to the given destination.
      void convertAndSend(D destination, java.lang.Object payload, MessagePostProcessor postProcessor)
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to the given destination.
      void convertAndSend(java.lang.Object payload)
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message and send it to a default destination.
      void convertAndSend(java.lang.Object payload, MessagePostProcessor postProcessor)
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message, apply the given post processor, and send the resulting message to a default destination.
      protected Message<?> doConvert(java.lang.Object payload, java.util.Map<java.lang.String,java.lang.Object> headers, MessagePostProcessor postProcessor)
      Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and apply the given post processor.
      protected abstract void doSend(D destination, Message<?> message) 
      D getDefaultDestination()
      Return the configured default destination.
      MessageConverter getMessageConverter()
      Return the configured MessageConverter.
      protected D getRequiredDefaultDestination() 
      protected java.util.Map<java.lang.String,java.lang.Object> processHeadersToSend(java.util.Map<java.lang.String,java.lang.Object> headers)
      Provides access to the map of input headers before a send operation.
      void send(D destination, Message<?> message)
      Send a message to the given destination.
      void send(Message<?> message)
      Send a message to a default destination.
      void setDefaultDestination(D defaultDestination)
      Configure the default destination to use in send methods that don't have a destination argument.
      void setMessageConverter(MessageConverter messageConverter)
      Set the MessageConverter to use in convertAndSend methods.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CONVERSION_HINT_HEADER

        public static final java.lang.String CONVERSION_HINT_HEADER
        Name of the header that can be set to provide further information (e.g. a MethodParameter instance) about the origin of the payload, to be taken into account as a conversion hint.
        Since:
        4.2
        See Also:
        Constant Field Values
      • logger

        protected final Log logger
    • Constructor Detail

      • AbstractMessageSendingTemplate

        public AbstractMessageSendingTemplate()
    • Method Detail

      • setDefaultDestination

        public void setDefaultDestination(@Nullable
                                          D defaultDestination)
        Configure the default destination to use in send methods that don't have a destination argument. If a default destination is not configured, send methods without a destination argument will raise an exception if invoked.
      • getDefaultDestination

        @Nullable
        public D getDefaultDestination()
        Return the configured default destination.
      • getRequiredDefaultDestination

        protected final D getRequiredDefaultDestination()
      • send

        public void send(D destination,
                         Message<?> message)
        Description copied from interface: MessageSendingOperations
        Send a message to the given destination.
        Specified by:
        send in interface MessageSendingOperations<D>
        Parameters:
        destination - the target destination
        message - the message to send
      • doSend

        protected abstract void doSend(D destination,
                                       Message<?> message)
      • convertAndSend

        public void convertAndSend(D destination,
                                   java.lang.Object payload,
                                   @Nullable
                                   java.util.Map<java.lang.String,java.lang.Object> headers)
                            throws MessagingException
        Description copied from interface: MessageSendingOperations
        Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and send it to the given destination.
        Specified by:
        convertAndSend in interface MessageSendingOperations<D>
        Parameters:
        destination - the target destination
        payload - the Object to use as payload
        headers - headers for the message to send
        Throws:
        MessagingException
      • convertAndSend

        public void convertAndSend(D destination,
                                   java.lang.Object payload,
                                   @Nullable
                                   java.util.Map<java.lang.String,java.lang.Object> headers,
                                   @Nullable
                                   MessagePostProcessor postProcessor)
                            throws MessagingException
        Description copied from interface: MessageSendingOperations
        Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers, apply the given post processor, and send the resulting message to the given destination.
        Specified by:
        convertAndSend in interface MessageSendingOperations<D>
        Parameters:
        destination - the target destination
        payload - the Object to use as payload
        headers - headers for the message to send
        postProcessor - the post processor to apply to the message
        Throws:
        MessagingException
      • doConvert

        protected Message<?> doConvert(java.lang.Object payload,
                                       @Nullable
                                       java.util.Map<java.lang.String,java.lang.Object> headers,
                                       @Nullable
                                       MessagePostProcessor postProcessor)
        Convert the given Object to serialized form, possibly using a MessageConverter, wrap it as a message with the given headers and apply the given post processor.
        Parameters:
        payload - the Object to use as payload
        headers - headers for the message to send
        postProcessor - the post processor to apply to the message
        Returns:
        the converted message
      • processHeadersToSend

        @Nullable
        protected java.util.Map<java.lang.String,java.lang.Object> processHeadersToSend(@Nullable
                                                                                                  java.util.Map<java.lang.String,java.lang.Object> headers)
        Provides access to the map of input headers before a send operation. Subclasses can modify the headers and then return the same or a different map.

        This default implementation in this class returns the input map.

        Parameters:
        headers - the headers to send (or null if none)
        Returns:
        the actual headers to send (or null if none)