Class NativeMessageHeaderAccessor

  • Direct Known Subclasses:
    JmsMessageHeaderAccessor, SimpMessageHeaderAccessor

    public class NativeMessageHeaderAccessor
    extends MessageHeaderAccessor
    An extension of MessageHeaderAccessor that also stores and provides read/write access to message headers from an external source -- e.g. a Spring Message created to represent a STOMP message received from a STOMP client or message broker. Native message headers are kept in a Map<String, List<String>> under the key NATIVE_HEADERS.

    This class is not intended for direct use but is rather expected to be used indirectly through protocol-specific sub-classes such as StompHeaderAccessor. Such sub-classes may provide factory methods to translate message headers from an external messaging source (e.g. STOMP) to Spring Message headers and reversely to translate Spring Message headers to a message to send to an external source.

    Rossen Stoyanchev
    • Field Detail


        public static final java.lang.String NATIVE_HEADERS
        The header name used to store native headers.
        See Also:
        Constant Field Values
    • Constructor Detail

      • NativeMessageHeaderAccessor

        protected NativeMessageHeaderAccessor()
        A protected constructor to create new headers.
      • NativeMessageHeaderAccessor

        protected NativeMessageHeaderAccessor(@Nullable
                                              java.util.Map<java.lang.String,java.util.List<java.lang.String>> nativeHeaders)
        A protected constructor to create new headers.
        nativeHeaders - native headers to create the message with (may be null)
      • NativeMessageHeaderAccessor

        protected NativeMessageHeaderAccessor(@Nullable
                                              Message<?> message)
        A protected constructor accepting the headers of an existing message to copy.
    • Method Detail

      • getNativeHeaders

        protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getNativeHeaders()
      • toNativeHeaderMap

        public java.util.Map<java.lang.String,java.util.List<java.lang.String>> toNativeHeaderMap()
        Return a copy of the native header values or an empty map.
      • containsNativeHeader

        public boolean containsNativeHeader(java.lang.String headerName)
        Whether the native header map contains the give header name.
      • getNativeHeader

        public java.util.List<java.lang.String> getNativeHeader(java.lang.String headerName)
        Return all values for the specified native header. or null if none.
      • getFirstNativeHeader

        public java.lang.String getFirstNativeHeader(java.lang.String headerName)
        Return the first value for the specified native header, or null if none.
      • setNativeHeader

        public void setNativeHeader(java.lang.String name,
                                    java.lang.String value)
        Set the specified native header value replacing existing values.
      • addNativeHeader

        public void addNativeHeader(java.lang.String name,
                                    java.lang.String value)
        Add the specified native header value to existing values.
      • addNativeHeaders

        public void addNativeHeaders(@Nullable
                                     MultiValueMap<java.lang.String,java.lang.String> headers)
      • removeNativeHeader

        public java.util.List<java.lang.String> removeNativeHeader(java.lang.String name)
      • getFirstNativeHeader

        public static java.lang.String getFirstNativeHeader(java.lang.String headerName,
                                                                      java.util.Map<java.lang.String,java.lang.Object> headers)