lihongjie0209 / myblog

4 stars 0 forks source link

Spring Integration: message #207

Open lihongjie0209 opened 3 years ago

lihongjie0209 commented 3 years ago

In Spring Integration, a message is a generic wrapper for any Java object combined with metadata used by the framework while handling that object. It consists of a payload and headers. The payload can be of any type, and the headers hold commonly required information such as ID, timestamp, correlation ID, and return address. Headers are also used for passing values to and from connected transports. For example, when creating a message from a received file, the file name may be stored in a header to be accessed by downstream components. Likewise, if a message’s content is ultimately going to be sent by an outbound mail adapter, the various properties (to, from, cc, subject, and others) may be configured as message header values by an upstream component. Developers can also store any arbitrary key-value pairs in the headers.

image

lihongjie0209 commented 3 years ago

org.springframework.messaging.Message


public interface Message<T> {

    /**
     * Return the message payload.
     */
    T getPayload();

    /**
     * Return message headers for the message (never {@code null} but may be empty).
     */
    MessageHeaders getHeaders();

}

org.springframework.messaging.MessageHeaders

public class MessageHeaders implements Map<String, Object>, Serializable {}